Project

esearch

0.0
No commit activity in last 3 years
No release in over 3 years
Esearch driver for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.2.0
~> 0.1.4
~> 0.0.9
~> 0.9.0
~> 1.9.2
~> 0.0.1
 Project Readme

esearch

Build Status Dependency Status Code Climate

Terminate the esearch API in a friendly ruby PORO api.

Installation

Install the gem esearch via your preferred method.

Examples

# Settings suitable for operation on single node
settings = {
  :settings => {
    :number_of_shards => 1,
    :number_of_replicas => 0
  }
)

# Connect to a cluster
cluster = Esearch::Cluster.connect(uri, Logger.new($stderr, :debug)) }

# Create index 
index_a = cluster.index('test-a')
index_a.exist? # => false, does not exist jet
index_a.create(settings) 
index_a.exist? # => true

# Create another index
index_b = cluster.index('test-b')
index_b.create(SINGLE_NODE_SETTINGS)

# Wait for cluster initialization
cluster.health(:wait_for_status => :green, :timeout => '10s')

# Access many indexes at once
indices = cluster.indices(%w(test-a test-b))

# Index some data
result_a = index_a.type('type-a').index({'foo' => 'bar'})
result_b = index_b.type('type-b').index({'foo' => 'baz'})

# Refresh indices
indices.refresh

# Query all documents in index a
result = index_a.search({:query => { :match_all => {}}})
result.hits.map(&:source) # => [{'foo' => 'bar'}]

# Query all documents across two indexes
result = indices.search({:query => { :match_all => {}}})
result.hits.map(&:source) # => [{'foo' => 'bar'}, {'foo' => 'baz'}]

# Delete a document
index_a.type('type-a').document(result_a.id).delete

# Query a document by id
document = index_b.type('type-b').document(result_b.id).get
document.source # => {'foo' => 'baz'}

Compatibility

Tested under {mri,jruby,rbx} > 1.8.

Credits

Contributing

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with Rakefile or version (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

License

This gem is published under the MIT license. See LICENSE file.