elastic_adapter 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e39324dd02ae383ab7d86347961777c2509b7e2
|
4
|
+
data.tar.gz: 99fbe0dad75178310acb85a33b6f7cb85c6743fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab2028e5051ea85cb5dbacd42867df674cd254b27f663de1691c0654cd56c468f90d1f7f40640bae4887b7e86d40d5394af7cea2b1743790d2c399099de95bc
|
7
|
+
data.tar.gz: 831382d5af0b6c00f678512dd5e939f231630ef7ad7f328b09add3b31c544122dd1fd17473817f9a608e1b376e2fb405b89488decb11c71071a6d02c32b34432
|
@@ -12,10 +12,12 @@ module ElasticAdapter
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def collect_hits
|
15
|
+
return [] unless object[:hits]
|
15
16
|
object[:hits][:hits].map { |hit| { id: hit[:id] }.merge(hit[:source]) }
|
16
17
|
end
|
17
18
|
|
18
19
|
def collect_aggregations
|
20
|
+
return [] unless object[:aggregations]
|
19
21
|
aggs = {}
|
20
22
|
object[:aggregations].each do |agg_name, result|
|
21
23
|
aggs[agg_name] = []
|
@@ -27,6 +29,7 @@ module ElasticAdapter
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def collect_suggestions
|
32
|
+
return [] unless object[:suggest]
|
30
33
|
object[:suggest].map { |suggestion_name, content|
|
31
34
|
# In this context key is the named suggestion
|
32
35
|
# returned by elasticsearch
|
@@ -58,6 +58,14 @@ module ElasticAdapter
|
|
58
58
|
|
59
59
|
subject { SearchResponse.new(response) }
|
60
60
|
|
61
|
+
context "empty response" do
|
62
|
+
let(:response) {{}}
|
63
|
+
|
64
|
+
it "should not fail" do
|
65
|
+
expect { subject }.not_to raise_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
61
69
|
describe "hits" do
|
62
70
|
it "returns the hits" do
|
63
71
|
expect(subject.hits).to include({
|