Skip to content

Commit

Permalink
Merge pull request #7 from phlipper/patch-1
Browse files Browse the repository at this point in the history
add GitHub Flavored Markdown to README
  • Loading branch information
jonmagic committed Dec 31, 2012
2 parents 24f8faa + 2c1abfb commit d8234b2
Showing 1 changed file with 43 additions and 25 deletions.
68 changes: 43 additions & 25 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,62 +6,80 @@ ElasticSearch ruby client. Credit goes to my coworkers at GitHub, I just turned


Add to Gemfile Add to Gemfile


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


Create connection: Create connection:


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


Index a document: Index a document:


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


Get a document: Get a document:


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


Get documents: Get documents:


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


Search: Search:


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


Remove record: Remove record:


es.remove(type, id) ```ruby
es.remove(type, id)
```


Remove by query: Remove by query:


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


Remove all of type: Remove all of type:


es.remove_all(type) ```ruby
es.remove_all(type)
```


## Note on Patches/Pull Requests ## Note on Patches/Pull Requests


* Fork the project. * Fork the project.
* Make your feature addition or bug fix. * 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. * 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) * 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. * Send us a pull request. Bonus points for topic branches.

0 comments on commit d8234b2

Please sign in to comment.