Skip to content
No description or website provided.
Ruby
Find file
Latest commit d8234b2 Dec 30, 2012 @jonmagic Merge pull request #7 from phlipper/patch-1
add GitHub Flavored Markdown to README
Failed to load latest commit information.
lib Bumped to 0.1.1 Jul 16, 2012
spec fix failing spec Jul 6, 2012
.gitignore First commit. Mar 5, 2012
Gemfile First commit. Mar 6, 2012
LICENSE First commit. Mar 6, 2012
README.md add GitHub Flavored Markdown to README Dec 30, 2012
Rakefile First commit. Mar 6, 2012
elasticsearch-client.gemspec use faraday 0.8 Jun 12, 2012

README.md

ElasticSearch ruby client

ElasticSearch ruby client. Credit goes to my coworkers at GitHub, I just turned it into a gem.

Usage

Add to Gemfile

gem 'elasticsearch-client', :require => 'elasticsearch'

Create connection:

index = 'twitter'
url = 'http://localhost:9200'
es = ElasticSearch::Index.new(index, url)

Index a document:

type = 'tweet'
doc = {:id => 'abcd', :foo => 'bar'}
es.add(type, doc[:id], doc)

Get a document:

id = '1234'
es.mget(type, [id])

Get documents:

id2 = 'abcd'
es.mget(type, [id, id2])

Search:

query = {
  :query => {
    :bool => {
      :must => {
        :query_string => {
          :default_field => '_all',
          :query => 'foobar!',
        }
      }
    }
  }
}
es.search(type, query)

Remove record:

es.remove(type, id)

Remove by query:

es.remove_by_query(type, :term => {:foo => 'bar'})

Remove all of type:

es.remove_all(type)

Note on Patches/Pull Requests

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