Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add GitHub Flavored Markdown to README #7

Merged
merged 1 commit into from

2 participants

@phlipper
  • This makes the example code easier to read, especially when perusing the docs on github
@phlipper phlipper add GitHub Flavored Markdown to README
* This makes the example code easier to read,
  especially when perusing the docs on github
2c1abfb
@jonmagic
Owner

:metal:

@jonmagic jonmagic merged commit d8234b2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2012
  1. @phlipper

    add GitHub Flavored Markdown to README

    phlipper authored
    * This makes the example code easier to read,
      especially when perusing the docs on github
This page is out of date. Refresh to see the latest.
Showing with 43 additions and 25 deletions.
  1. +43 −25 README.md
View
68 README.md
@@ -6,57 +6,75 @@ ElasticSearch ruby client. Credit goes to my coworkers at GitHub, I just turned
Add to Gemfile
- gem 'elasticsearch-client', :require => 'elasticsearch'
+```ruby
+gem 'elasticsearch-client', :require => 'elasticsearch'
+```
Create connection:
- index = 'twitter'
- url = 'http://localhost:9200'
- es = ElasticSearch::Index.new(index, url)
+```ruby
+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)
+```ruby
+type = 'tweet'
+doc = {:id => 'abcd', :foo => 'bar'}
+es.add(type, doc[:id], doc)
+```
Get a document:
- id = '1234'
- es.mget(type, [id])
+```ruby
+id = '1234'
+es.mget(type, [id])
+```
Get documents:
- id2 = 'abcd'
- es.mget(type, [id, id2])
+```ruby
+id2 = 'abcd'
+es.mget(type, [id, id2])
+```
Search:
- query = {
- :query => {
- :bool => {
- :must => {
- :query_string => {
- :default_field => '_all',
- :query => 'foobar!',
- }
- }
+```ruby
+query = {
+ :query => {
+ :bool => {
+ :must => {
+ :query_string => {
+ :default_field => '_all',
+ :query => 'foobar!',
}
}
}
- es.search(type, query)
+ }
+}
+es.search(type, query)
+```
Remove record:
- es.remove(type, id)
+```ruby
+es.remove(type, id)
+```
Remove by query:
- es.remove_by_query(type, :term => {:foo => 'bar'})
+```ruby
+es.remove_by_query(type, :term => {:foo => 'bar'})
+```
Remove all of type:
- es.remove_all(type)
+```ruby
+es.remove_all(type)
+```
## Note on Patches/Pull Requests
@@ -64,4 +82,4 @@ Remove all of type:
* 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.
+* Send us a pull request. Bonus points for topic branches.
Something went wrong with that request. Please try again.