Permalink
Browse files

Added remove_all and updated README

  • Loading branch information...
1 parent 9428f74 commit e3d0b0a3b23c7343ba8d0dfbce57a8b2502d21f9 @jonmagic committed Mar 6, 2012
Showing with 29 additions and 4 deletions.
  1. +18 −4 README.md
  2. +11 −0 lib/elasticsearch.rb
View
@@ -16,13 +16,19 @@ Create connection:
Index a document:
+ type = 'tweet'
doc = {:id => 'abcd', :foo => 'bar'}
- es.add(index, doc[:id], doc)
+ es.add(type, doc[:id], doc)
Get a document:
id = '1234'
- es.mget(id)
+ es.mget(type, [id])
+
+Get documents:
+
+ id2 = 'abcd'
+ es.mget(type, [id, id2])
Search:
@@ -38,11 +44,19 @@ Search:
}
}
}
- es.search(index, query)
+ es.search(type, query)
Remove record:
- es.remove_by_query(index, :term => {:id => id})
+ 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
View
@@ -156,6 +156,17 @@ def remove(type, id)
end
end
+ # Remove all of a type from this index
+ #
+ # type - the type of document to be removed
+ #
+ # Returns a hash, the parsed response body from elasticsearch
+ def remove_all(type)
+ delete do |req|
+ req.url "#{@name}/#{type}"
+ end
+ end
+
# Remove a collection of documents matched by a query
#
# types - the type or types to query

0 comments on commit e3d0b0a

Please sign in to comment.