rubberband 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -17,3 +17,6 @@ cuke_*.log
17
17
 
18
18
  # ctags generated
19
19
  tags
20
+
21
+ # Gemfile.lock should not be checked in for gems
22
+ Gemfile.lock
@@ -89,10 +89,13 @@ module ElasticSearch
89
89
  end
90
90
 
91
91
  # Uses a post request so we can send ids in content
92
- def multi_get(index, type, ids, options={})
92
+ def multi_get(index, type, query, options={})
93
93
  # { "docs" = [ {...}, {...}, ...]}
94
+ if query.is_a?(Array)
95
+ query = { "ids" => query }
96
+ end
94
97
  results = standard_request(:post, { :index => index, :type => type, :op => "_mget"},
95
- options, encoder.encode({"ids" => ids}))['docs']
98
+ options, encoder.encode(query))['docs']
96
99
  results.each do |hit|
97
100
  unescape_id!(hit)
98
101
  set_encoding!(hit)
@@ -1,3 +1,3 @@
1
1
  module ElasticSearch
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -52,7 +52,7 @@ describe "index ops" do
52
52
  @client.count(:term => { :deleted => 'bar'}).should == 0
53
53
  end
54
54
 
55
- it 'should perform a successful multi get' do
55
+ it 'should perform a successful multi get with an array' do
56
56
  @client.index({:foo => "bar"}, :id => "1")
57
57
  @client.index({:foo => "baz"}, :id => "2")
58
58
  @client.index({:foo => "bazbar"}, :id => "3")
@@ -60,4 +60,25 @@ describe "index ops" do
60
60
  results = @client.multi_get(ids).inject([]) { |r,e| r << e.id }
61
61
  results.should == ids
62
62
  end
63
+
64
+ it 'should perform a successful multi get' do
65
+ @client.index({:foo => "bar", :bar => "boo1"}, :id => "1")
66
+ @client.index({:foo => "baz", :bar => "boo2"}, :id => "2")
67
+ @client.index({:foo => "bazbar", :bar => "boo3"}, :id => "3")
68
+ query = {
69
+ "docs" => [
70
+ { "_id" => "1", "fields" => [] },
71
+ { "_id" => "2" },
72
+ { "_id" => "3", "fields" => ["foo"] },
73
+ ]
74
+ }
75
+ results = @client.multi_get(query).inject([]) do
76
+ |r,e| r << { "id" => e.id, "fields" => e.fields, "_source" => e._source }
77
+ end
78
+ results.should == [
79
+ { "id" => "1", "fields" => nil, "_source" => nil },
80
+ { "id" => "2", "fields" => nil, "_source" => { "foo" => "baz", "bar" => "boo2" } },
81
+ { "id" => "3", "fields" => { "foo" => "bazbar" }, "_source" => nil },
82
+ ]
83
+ end
63
84
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubberband
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grant Rodgers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-22 00:00:00 Z
18
+ date: 2011-10-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: patron
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  requirements: []
224
224
 
225
225
  rubyforge_project: rubberband
226
- rubygems_version: 1.8.6
226
+ rubygems_version: 1.8.10
227
227
  signing_key:
228
228
  specification_version: 3
229
229
  summary: An ElasticSearch client with ThriftClient-like failover handling.
@@ -236,3 +236,4 @@ test_files:
236
236
  - spec/index_spec.rb
237
237
  - spec/spec_helper.rb
238
238
  - spec/type_spec.rb
239
+ has_rdoc: