Elasticsearch Now Available in Beta

Elasticsearch, a distributed, RESTful search and analytics engine, is now available to use with Nanobox apps. Nanobox's support of Elasticsearch is currently in beta, but please feel free to use and test it.

Create an Elasticsearch Component

To include an Elasticsearch component in your app, add a data component to your boxfile.yml with the image set to nanobox/elasticsearch:5:

data.elasticsearch:
  image: nanobox/elasticsearch:5

Re-Run Your App Locally

The next time you run your app locally, Nanobox will detect the change to your boxfile.yml, rebuild your runtime, and provision your Elasticsearch component.

nanobox run

Install Client Drivers, Connect, & Setup

With Elasticsearch running, install any necessary client drivers, connect to Elasticsearch, and set up your dataset. How you do this depends on the language you’re using:

Elasticsearch Clients

Note: These instructions should be followed from within the Nanobox console after you run nanobox run.

Connect to Elasticsearch

Nanobox will auto-generate a _HOST environment variable to use when connecting to Elasticsearch. Using the auto-generated environment variable in your connection config will keep your app portable across environments. The environment variable key is based off your database's component ID.

Any Elasticsearch database created with Nanobox will always listen on the default port, 9200.

Node.js Connection Example

var elasticsearch = require('elasticsearch');

var client = new elasticsearch.Client( {  
  host: process.env.DATA_ELASTICSEARCH_HOST + ':9200/'
});

Important To Note

Elasticsearch is a memory-intensive service. Without enough RAM, it will not be able to start. When deploying to production, you will likely need to scale beyond the default server size (depending on your provider).

If creating a brand new app, scale your application server before deploying the first time. Plan on at least 1GB of RAM for Elasticsearch in addition to the resources required by your app's other components.

Elasticsearch with Nanobox
Managing Local Elasticsearch Data with Nanobox
Managing Production Elasticsearch Data with Nanobox

Posted in Features, Updates