rubberband 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/elasticsearch/client/index.rb +8 -8
- data/lib/elasticsearch/transport/base_protocol.rb +2 -2
- data/rubberband.gemspec +2 -2
- data/spec/bulk_spec.rb +3 -0
- data/spec/index_spec.rb +9 -0
- data/spec/type_spec.rb +1 -0
- metadata +4 -4
@@ -14,6 +14,7 @@ module ElasticSearch
|
|
14
14
|
|
15
15
|
id = options.delete(:id)
|
16
16
|
if @batch
|
17
|
+
#TODO add routing, parent
|
17
18
|
@batch << { :index => { :_index => index, :_type => type, :_id => id }}
|
18
19
|
@batch << document
|
19
20
|
else
|
@@ -43,6 +44,7 @@ module ElasticSearch
|
|
43
44
|
index, type, options = extract_required_scope(options)
|
44
45
|
|
45
46
|
if @batch
|
47
|
+
#TODO add routing, parent
|
46
48
|
@batch << { :delete => { :_index => index, :_type => type, :_id => id }}
|
47
49
|
else
|
48
50
|
result = execute(:delete, index, type, id, options)
|
@@ -71,14 +73,12 @@ module ElasticSearch
|
|
71
73
|
|
72
74
|
options[:fields] = "_id" if options[:ids_only]
|
73
75
|
|
74
|
-
# options that hits take: per_page, page, ids_only
|
75
|
-
hits_options = options.select { |k, v| [:per_page, :page, :ids_only].include?(k) }
|
76
|
-
|
77
76
|
# options that elasticsearch doesn't recognize: page, per_page, ids_only, limit, offset
|
78
|
-
options.reject
|
77
|
+
search_options = options.reject { |k, v| [:page, :per_page, :ids_only, :limit, :offset].include?(k) }
|
78
|
+
|
79
|
+
response = execute(:search, index, type, query, search_options)
|
79
80
|
|
80
|
-
response
|
81
|
-
Hits.new(response, hits_options).freeze #ids_only returns array of ids instead of hits
|
81
|
+
Hits.new(response, {:per_page => options[:per_page], :page => options[:page], :ids_only => options[:ids_only]}).freeze #ids_only returns array of ids instead of hits
|
82
82
|
end
|
83
83
|
|
84
84
|
#ids_only Return ids instead of hits
|
@@ -99,10 +99,10 @@ module ElasticSearch
|
|
99
99
|
|
100
100
|
# Starts a bulk operation batch and yields self. Index and delete requests will be
|
101
101
|
# queued until the block closes, then sent as a single _bulk call.
|
102
|
-
def bulk
|
102
|
+
def bulk(options={})
|
103
103
|
@batch = []
|
104
104
|
yield(self)
|
105
|
-
response = execute(:bulk, @batch)
|
105
|
+
response = execute(:bulk, @batch, options)
|
106
106
|
ensure
|
107
107
|
@batch = nil
|
108
108
|
end
|
@@ -69,9 +69,9 @@ module ElasticSearch
|
|
69
69
|
encoder.decode(response.body) # {"count", "_shards"=>{"failed", "total", "successful"}}
|
70
70
|
end
|
71
71
|
|
72
|
-
def bulk(actions)
|
72
|
+
def bulk(actions, options={})
|
73
73
|
body = actions.inject("") { |a, s| a << encoder.encode(s) << "\n" }
|
74
|
-
response = request(:post, {:op => '_bulk'},
|
74
|
+
response = request(:post, {:op => '_bulk'}, options, body)
|
75
75
|
handle_error(response) unless response.status == 200
|
76
76
|
encoder.decode(response.body) # {"items => [ {"delete"/"create" => {"_index", "_type", "_id", "ok"}} ] }
|
77
77
|
end
|
data/rubberband.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rubberband}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["grantr"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-23}
|
13
13
|
s.description = %q{An ElasticSearch client with ThriftClient-like failover handling.}
|
14
14
|
s.email = %q{grantr@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/bulk_spec.rb
CHANGED
data/spec/index_spec.rb
CHANGED
@@ -31,4 +31,13 @@ describe "index ops" do
|
|
31
31
|
@client.search(:query => { :term => { :foo => 'baz' }}).should have(2).items
|
32
32
|
@client.count(:term => { :foo => 'baz' }).should == 2
|
33
33
|
end
|
34
|
+
|
35
|
+
it 'should return ids when given :ids_only' do
|
36
|
+
@client.index({:socks => "stripey"}, :id => "5")
|
37
|
+
@client.index({:stripey => "stripey too"}, :id => "6")
|
38
|
+
@client.refresh
|
39
|
+
|
40
|
+
results = @client.search({:query => { :field => { :socks => 'stripey' }}}, :ids_only => true)
|
41
|
+
results.should include("5")
|
42
|
+
end
|
34
43
|
end
|
data/spec/type_spec.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- grantr
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-23 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -237,7 +237,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
237
237
|
requirements:
|
238
238
|
- - ">="
|
239
239
|
- !ruby/object:Gem::Version
|
240
|
-
hash:
|
240
|
+
hash: -2113882144738525775
|
241
241
|
segments:
|
242
242
|
- 0
|
243
243
|
version: "0"
|