stretcher 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/stretcher/index.rb
CHANGED
@@ -73,11 +73,12 @@ module Stretcher
|
|
73
73
|
# Unless the exception is hit we know its a 2xx response
|
74
74
|
request(:head)
|
75
75
|
true
|
76
|
-
rescue Stretcher::RequestError
|
77
|
-
raise e if e.http_response.status != 404
|
76
|
+
rescue Stretcher::RequestError::NotFound
|
78
77
|
false
|
79
78
|
end
|
80
|
-
|
79
|
+
|
80
|
+
# Delete documents by a given query.
|
81
|
+
# Per: http://www.elasticsearch.org/guide/reference/api/delete-by-query.html
|
81
82
|
def delete_query(query)
|
82
83
|
do_delete_query(query)
|
83
84
|
end
|
@@ -21,7 +21,10 @@ module Stretcher
|
|
21
21
|
self.results = raw.hits.hits.collect do |r|
|
22
22
|
k = ['_source', 'fields'].detect { |k| r.key?(k) }
|
23
23
|
doc = k.nil? ? Hashie::Mash.new : r[k]
|
24
|
-
|
24
|
+
if r.key?('highlight')
|
25
|
+
doc.merge!({"_highlight" => r['highlight']})
|
26
|
+
end
|
27
|
+
doc.merge!({"_id" => r['_id']})
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
data/lib/stretcher/version.rb
CHANGED
@@ -32,19 +32,25 @@ describe Stretcher::IndexType do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should search and find the right doc" do
|
35
|
-
res = type.search(
|
35
|
+
res = type.search(:query => {:match => {:message => @doc[:message]}})
|
36
36
|
res.results.first.message.should == @doc[:message]
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should build results when _source is not included in loaded fields" do
|
40
|
-
res = type.search(
|
40
|
+
res = type.search(query: {match_all: {}}, fields: ['message'])
|
41
41
|
res.results.first.message.should == @doc[:message]
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should build results when no document fields are selected" do
|
45
|
-
res = type.search(
|
45
|
+
res = type.search(query: {match_all: {}}, fields: ['_id'])
|
46
46
|
res.results.first.should have_key '_id'
|
47
47
|
end
|
48
|
+
|
49
|
+
it "should add _highlight field to resulting documents when present" do
|
50
|
+
res = type.search(:query => {:match => {:message => 'hello'}}, :highlight => {:fields => {:message => {}}})
|
51
|
+
res.results.first.message.should == @doc[:message]
|
52
|
+
res.results.first.should have_key '_highlight'
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
describe "put/get/delete" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|