Bonsai offers a Heroku add-on for ElasticSearch.
ElasticSearch is the latest generation search engine built on the powerful Lucene library. Its API is freshly designed around modern RESTful JSON conventions, making it easy to learn and understand. ElasticSearch will automatically index your JSON data with sensible defaults, which means that you can get started without writing a single line of configuration. ElasticSearch is the perfect place to start for anyone new to full-text search engine concepts, or for anyone who is looking for more clarity and less ceremony in their search engine.
The ElasticSearch internals are designed from the ground up with data distribution in mind. This means you get greater scalability, performance and reliability in a cloud hosted environment. An ElasticSearch index can automatically shard your data, to scale to the largest indexes and support high volumes of write traffic. All of our plans also offer replication by default, with transparent hot failover, and the ability to scale your replicas for high volumes of read traffic.
You have more important things to work on than managing and scaling another set of servers. With Bonsai, you get solid, scalable technology that is easy to use and understand, and managed by experts. All you have to worry about is putting it to use to build great features for your customers.
The Bonsai add-on provides an ElasticSearch index to your application, which is available to any language and platform that can send JSON to its RESTful HTTP API. You may also opt to use one of the many open source ElasticSearch clients for tighter integration with languages and frameworks such as, in no particular order, Ruby, Ruby on Rails, Python, Django, PHP, Erlang, Clojure, Java, Play! and Perl.
Bonsai ElasticSearch can be installed to a Heroku application via the heroku
CLI:
:::term
$ heroku addons:add bonsai
-----> Adding bonsai to sharp-mountain-4005... done, v18 (free)
Once Bonsai ElasticSearch has been added, the BONSAI_URL
environment variable will be available in your app's configuration. This will contain the canonical URL and credentials to your ElasticSearch Cluster. You can check the value of this variable with the heroku config
comand:
:::term
$ heroku config | grep BONSAI
BONSAI_URL => http://ql9lsrn8:[email protected]/
After installing Bonsai ElasticSearch, your application may create an index and start using it right away.
Many ElasticSearch clients will take care of creating an index for you. You should review your client's documentation for more information on its index usage conventions. If you don't know how many indexes your application needs, we recommend creating one index per application per environment, to correspond with your database.
Let's create an example index called acme-production
from the command line with curl
. Note that your application's BONSAI_URL
will contain a username and a password which is used to authenticate index creation, modification and deletion.
:::term
$ curl -X POST http://ql9lsrn8:[email protected]/acme-production
{"ok":true,"acknowledged":true}
Let's insert a "Hello, world" test document to verify that your new index is available, and to highlight some basic ElasticSearch concepts.
First and foremost, ElasticSearch is a JSON document store. You can use HTTP REST methods to create, update, fetch and destroy JSON documents. Every JSON document should specify an id and a type. You you may specify these values with the _id
and the _type
keys, or ElasticSearch will infer them from the URL of its API endpoints.
In the following example, we HTTP POST a simple JSON document to a URL which specifies a _type
of test
and an _id
of hello
. You should replace the sample URL in this document with your own index URL to follow along.
:::term
$ curl -XPOST http://redwood-94865.us-east-1.bonsai.io/acme-production/test/hello -d '{"title":"Hello world"}'
{
"ok" : true,
"_index" : "acme-production",
"_type" : "test",
"_id" : "hello",
"_version" : 1
}
ElasticSearch will index the document you provide based on sensible defaults for later searching. You can also see some of the values you provided echoed back in the output, along with a few other default fields, which will be explained elsewhere.
Next, you may view this document by issuing a HTTP GET request to its URL.
:::term
$ curl -XGET 'http://redwood-94865.us-east-1.bonsai.io/acme-production/test/hello'
{
"_index" : "acme-production",
"_type" : "test",
"_id" : "hello",
"_version" : 1,
"exists" : true,
"_source" : { "title":"hello world" }
}
To learn more about about the operations supported by your index, you should read the ElasticSearch Index API documentation. Note that some operations mentioned in the documentation (such as "Automatic Index Creation") are for administrative purposes, and will be restricted in our environment.
ElasticSearch is open source software, and you can download and install your own instance for a local development and testing environment.
:::term
$ brew install elasticsearch
You may download the latest ElasticSearch release from http://www.elasticsearch.org/download/. The downloaded package will contain a standalone elasticsearch
executable.
:::term
$ curl -k -L -O http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.10.tar.gz
$ tar -zxvf elasticsearch-0.19.10.tar.gz
$ ./elasticsearch-0.19.10/bin/elasticsearch -f
We also recommend using Foreman for starting and starting ElasticSearch locally. A sample Procfile may look like this:
elasticsearch: path/to/elasticsearch -f
You should also run heroku ps:scale elasticsearch=0
on your next deploy to avoid attempting to run this command on Heroku.
Tire is a popular Ruby on Rails client for ElasticSearch. To integrate Tire with ElasticSearch, you will need to set the ELASTICSEARCH_URL
config variable to BONSAI_URL
. To do so, add the following to config/initializers/bonsai.rb
:
:::ruby
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
Please refer to https://gist.github.com/2041121 for more details, and to offer feedback, on Tire integration.
The Bonsai ElasticSearch dashboard shows you basic information about your account and. The dashboard can be accessed via the CLI:
:::term
$ heroku addons:open bonsai
Opening bonsai for sharp-mountain-4005…
Or by selecting Bonsai ElasticSearch from your application's page on the the Heroku dashboard.
Some ElasticSearch actions have been limited for administrative use only within our shared cluster. In general, this applies to any action outside of your index, or to updating certain system-level attributes of your index (such as shards or replicas).
Notably, if you receive this error when you try to PUT
a new mapping to the root of your index, you should instead use the _mapping
action within your index.
Note that the provided URL is for an index. Your request should be to a URL in the form of one of the following:
http://account.region.bonsai.io/index_name
http://account.region.bonsai.io/index_name/_verb
http://account.region.bonsai.io/index_name/type_name
http://account.region.bonsai.io/index_name/type_name/_verb
http://account.region.bonsai.io/index_name/type_name/document_id
http://account.region.bonsai.io/index_name/type_name/document_id/_verb
We also provide three Cluster-level actions at this time:
http://region.bonsai.io/
— cluster root URL, for cluster health checkshttp://account.region.bonsai.io/
— cluster root URL, for cluster health checkshttp://account.region.bonsai.io/_bulk
— cluster bulk import handlerhttp://account.region.bonsai.io/_search/scroll
— scrolling search handler
Our plans are primarily metered on replication level, and also on the number of shards allowed to a plan.
Indexes created within our starter-level plans have no replication, and are not intended for production traffic. An index created within our production-level plans will be replicated for higher availability and higher search traffic.
For greater data capacity, an index may be partitioned into many shards. Each shard is distributed to a different server within our cluster to allocate more resources for each search, and help scale to ever increasing quantities of data.
When changing your plan, we will adjust the replication level of any existing indices, as well as add or remove shards as per your new plan. If you have upgraded to a plan with additional shards, you may create a new index and must migrate your data
Bonsai ElasticSearch can be removed via the CLI.
:::term
$ heroku addons:remove bonsai
-----> Removing bonsai from sharp-mountain-4005... done, v20 (free)
All Bonsai ElasticSearch support and runtime issues should be logged with Heroku Support at https://support.heroku.com. Please include your app name and index URL, and if possible, a reproduction of the issue with curl
.
Any product feedback or non-support related issues is welcome via Twitter at @bonsaisearch or email to [email protected].
- Official ElasticSearch home page and API documentation
- ElasticSearch user mailing list
- ElasticSearch Q&A on Stack Overflow
- ElasticSearch source code on GitHub
Found a typo? Have a client to recommend, or an interesting question? Comment on this gist.
Are you sure this is the official ElasticSearch homepage? http://bonsai.org/ looks like it's all about little trees :P. (Even more of a give away - it's backed by Joomla )