2013-11-04 05:46:36 -05:00
|
|
|
= elasticsearch-ruby
|
|
|
|
|
|
|
|
== Overview
|
|
|
|
|
|
|
|
There's a suite of official Ruby libraries for Elasticsearch, which provide a client for connecting
|
|
|
|
to Elasticsearch clusters, Ruby interface to the REST API, and more.
|
|
|
|
|
|
|
|
See the full documentation at http://github.com/elasticsearch/elasticsearch-ruby.
|
|
|
|
|
2014-02-10 05:58:42 -05:00
|
|
|
=== Elasticsearch Version Compatibility
|
|
|
|
|
|
|
|
The Ruby libraries are compatible with both Elasticsearch 0.90.x and 1.0.x versions,
|
2014-02-11 10:12:53 -05:00
|
|
|
but you have to install a matching http://rubygems.org/gems/elasticsearch/versions[gem version]:
|
2014-02-10 05:58:42 -05:00
|
|
|
|
|
|
|
[cols="<,<",options="header",]
|
|
|
|
|=========================================
|
|
|
|
| Elasticsearch version | Ruby gem version
|
|
|
|
| 0.90.x | 0.4.x
|
|
|
|
| 1.0.x | 1.x
|
|
|
|
|=========================================
|
2013-11-04 05:46:36 -05:00
|
|
|
|
|
|
|
=== Installation
|
|
|
|
|
2014-02-10 05:58:42 -05:00
|
|
|
Install the Ruby gem for Elasticsearch *1.x*:
|
2013-11-04 05:46:36 -05:00
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
------------------------------------
|
|
|
|
gem install elasticsearch
|
|
|
|
------------------------------------
|
|
|
|
|
2014-02-10 05:58:42 -05:00
|
|
|
...or add it do your Gemfile:
|
2013-11-04 05:46:36 -05:00
|
|
|
|
|
|
|
[source,ruby]
|
|
|
|
------------------------------------
|
|
|
|
gem 'elasticsearch'
|
|
|
|
------------------------------------
|
|
|
|
|
2014-02-10 05:58:42 -05:00
|
|
|
Install the Ruby gem for Elasticsearch *0.90.x*:
|
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
------------------------------------
|
2014-02-11 10:12:53 -05:00
|
|
|
gem install elasticsearch -v 0.4.10
|
2014-02-10 05:58:42 -05:00
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
...or add it do your Gemfile:
|
|
|
|
|
|
|
|
[source,ruby]
|
|
|
|
------------------------------------
|
|
|
|
gem 'elasticsearch', '~> 0.4'
|
|
|
|
------------------------------------
|
2013-11-04 05:46:36 -05:00
|
|
|
|
|
|
|
=== Example Usage
|
|
|
|
|
|
|
|
[source,ruby]
|
|
|
|
------------------------------------
|
|
|
|
require 'elasticsearch'
|
|
|
|
|
|
|
|
client = Elasticsearch::Client.new log: true
|
|
|
|
|
|
|
|
client.cluster.health
|
|
|
|
|
|
|
|
client.index index: 'my-index', type: 'my-document', id: 1, body: { title: 'Test' }
|
|
|
|
|
|
|
|
client.indices.refresh index: 'my-index'
|
|
|
|
|
|
|
|
client.search index: 'my-index', body: { query: { match: { title: 'test' } } }
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
=== Features at a Glance
|
|
|
|
|
|
|
|
* Pluggable logging and tracing
|
|
|
|
* Plugabble connection selection strategies (round-robin, random, custom)
|
|
|
|
* Pluggable transport implementation, customizable and extendable
|
|
|
|
* Pluggable serializer implementation
|
|
|
|
* Request retries and dead connections handling
|
|
|
|
* Node reloading (based on cluster state) on errors or on demand
|
|
|
|
* Modular API implementation
|
|
|
|
* 100% REST API coverage
|
|
|
|
|
|
|
|
|
|
|
|
== Copyright and License
|
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Elasticsearch BV.
|
|
|
|
|
|
|
|
This is free software, licensed under The Apache License Version 2.0.
|