elastic_adapter 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/elastic_adapter.gemspec +1 -1
- data/lib/elastic_adapter/decoration/aggregation_response.rb +34 -0
- data/lib/elastic_adapter/decoration/response_decorator_factory.rb +12 -14
- data/lib/elastic_adapter/index.rb +20 -7
- data/lib/elastic_adapter/response.rb +0 -7
- data/lib/elastic_adapter/version.rb +1 -1
- data/lib/elastic_adapter.rb +1 -0
- data/spec/cassettes/ElasticAdapter_Index/_aggregate/response/is_a_AggregationResponse.yml +30 -0
- data/spec/cassettes/ElasticAdapter_Index/_aggregate.yml +84 -0
- data/spec/decoration/aggregation_response_spec.rb +58 -0
- data/spec/decoration/response_decorator_factory_spec.rb +33 -30
- data/spec/index/aggregation_spec.rb +34 -0
- data/spec/response_spec.rb +7 -23
- metadata +12 -4
- data/example.env +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25e0579bbeba803053caee8b5986f7b02f7f719c
|
4
|
+
data.tar.gz: 1280437e020532bc8c67fc55555fad96ac9bd1e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577612284345aea4de48577b3d01c462326605e0b16531947fea2366c0ec5e4e43eac8a1687ed6942db07d559a992e29b41195d89e20e24f39d4e03a0ff84a3a
|
7
|
+
data.tar.gz: ef247ad391ecc75e53f322f9a8fb659a26eb2de46f4cbd50354428a146a35028beccdf70687c043d1818cc1a578664b4bb45b7fdd99171634854ce59ef273840
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://travis-ci.org/kbredemeier/elastic_adatper) [](https://codeclimate.com/github/kbredemeier/elastic_adatper)
|
2
2
|
|
3
3
|
# ElasticAdapter
|
4
4
|
|
data/elastic_adapter.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["k.bredemeier@gmail.com"]
|
11
11
|
spec.summary = %q{Repository like access to elasticseach indices}
|
12
12
|
spec.description = %q{Repository like access to elasticseach indices}
|
13
|
-
spec.homepage = "https://github.com/kbredemeier/
|
13
|
+
spec.homepage = "https://github.com/kbredemeier/elastic_adapter"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ElasticAdapter
|
2
|
+
module Decoration
|
3
|
+
# Used to decorate responses from the elasticsearch search api
|
4
|
+
#
|
5
|
+
# @attr_reader [Hash] aggregations
|
6
|
+
class AggregationResponse < Decorator
|
7
|
+
attr_reader :aggregations
|
8
|
+
|
9
|
+
# Reduces the interface
|
10
|
+
#
|
11
|
+
# @param [Hash] hash
|
12
|
+
# @return [Hash]
|
13
|
+
def alter_object(hash)
|
14
|
+
new_hash = {}
|
15
|
+
new_hash[:aggregations] = {}
|
16
|
+
|
17
|
+
hash[:aggregations].each do |key, value|
|
18
|
+
new_hash[:aggregations][key] = []
|
19
|
+
|
20
|
+
value[:buckets].each do |agg|
|
21
|
+
new_hash[:aggregations][key] << {
|
22
|
+
term: agg[:key],
|
23
|
+
count: agg[:doc_count]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
@aggregations = new_hash[:aggregations]
|
29
|
+
|
30
|
+
new_hash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -6,23 +6,21 @@ module ElasticAdapter
|
|
6
6
|
# @see Response#decorate
|
7
7
|
class ResponseDecoratorFactory
|
8
8
|
class << self
|
9
|
-
# Takes a response and
|
10
|
-
# applied
|
9
|
+
# Takes a response and multiple symbols and decorated response.
|
11
10
|
#
|
12
11
|
# @param [Hash] response a response returned by elasticsearch
|
12
|
+
# @param [Array<Symbol>] args the decorators the response should be decorated with.
|
13
|
+
# Currently valid args are :count, :hit, :search, :validation, :suggestion
|
13
14
|
# @return [Docorator] a decorated response
|
14
|
-
def decorate(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
elsif suggestion?(response)
|
24
|
-
return SuggestionResponse.new(response)
|
25
|
-
end
|
15
|
+
def decorate(plain_response, *args)
|
16
|
+
response = Response.new(plain_response)
|
17
|
+
|
18
|
+
response = CountResponse.new(response) if args.include? :count
|
19
|
+
response = HitDecorator.new(response) if args.include? :hit
|
20
|
+
response = SearchResponse.new(response) if args.include? :search
|
21
|
+
response = ValidationResponse.new(response) if args.include? :validation
|
22
|
+
response = SuggestionResponse.new(response) if args.include? :suggestion
|
23
|
+
response = AggregationResponse.new(response) if args.include? :aggregation
|
26
24
|
|
27
25
|
response
|
28
26
|
end
|
@@ -85,7 +85,7 @@ module ElasticAdapter
|
|
85
85
|
# @param [Hash] query a query to count the documents for a given query. Defaults to match all
|
86
86
|
# @return [Decoration::CountResponse] the count
|
87
87
|
def count(query = { query: { match_all: {} } })
|
88
|
-
handle_api_call do
|
88
|
+
handle_api_call :count do
|
89
89
|
client.count index: name, body: query
|
90
90
|
end
|
91
91
|
end
|
@@ -125,7 +125,7 @@ module ElasticAdapter
|
|
125
125
|
# @param [Integer] id
|
126
126
|
# @return [ElasticAdapter::HitDecorator]
|
127
127
|
def get(id)
|
128
|
-
handle_api_call do
|
128
|
+
handle_api_call :hit do
|
129
129
|
client.get(
|
130
130
|
index: name,
|
131
131
|
type: document_type.name,
|
@@ -145,7 +145,7 @@ module ElasticAdapter
|
|
145
145
|
# @param [Hash] query
|
146
146
|
# @return [ElasticAdapter::SearchResponse]
|
147
147
|
def search(query)
|
148
|
-
handle_api_call do
|
148
|
+
handle_api_call :search do
|
149
149
|
client.search(
|
150
150
|
index: name,
|
151
151
|
body: query
|
@@ -164,7 +164,7 @@ module ElasticAdapter
|
|
164
164
|
# @param [Hash] query
|
165
165
|
# @return [ElasticAdapter::SuggestResponse]
|
166
166
|
def suggest(query)
|
167
|
-
handle_api_call do
|
167
|
+
handle_api_call :suggestion do
|
168
168
|
client.suggest(
|
169
169
|
index: name,
|
170
170
|
body: query
|
@@ -179,7 +179,7 @@ module ElasticAdapter
|
|
179
179
|
# @param [Hash] query
|
180
180
|
# @return [ElasticAdapter::ValidationResponse]
|
181
181
|
def validate(query)
|
182
|
-
handle_api_call do
|
182
|
+
handle_api_call :validation do
|
183
183
|
client.indices.validate_query(
|
184
184
|
index: name,
|
185
185
|
explain: true,
|
@@ -188,10 +188,23 @@ module ElasticAdapter
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
+
# Executes a search request and wraps the response in an AggregationResponse
|
192
|
+
#
|
193
|
+
# @param [Hash] query
|
194
|
+
# @return [ElasticAdapter::Decoration::AggregationResponse]
|
195
|
+
def aggregate(query)
|
196
|
+
handle_api_call :aggregation do
|
197
|
+
client.search(
|
198
|
+
index: name,
|
199
|
+
body: query
|
200
|
+
)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
191
204
|
private
|
192
205
|
|
193
|
-
def handle_api_call
|
194
|
-
|
206
|
+
def handle_api_call(*args)
|
207
|
+
Decoration::ResponseDecoratorFactory.decorate(yield, *args)
|
195
208
|
rescue Elasticsearch::Transport::Transport::Error => e
|
196
209
|
Response.new(
|
197
210
|
exception: e
|
@@ -15,13 +15,6 @@ module ElasticAdapter
|
|
15
15
|
key?(:exception)
|
16
16
|
end
|
17
17
|
|
18
|
-
# Decorates the response with the right decorator
|
19
|
-
#
|
20
|
-
# @return [Decorator] returns the decorated response
|
21
|
-
def decorate
|
22
|
-
Decoration::ResponseDecoratorFactory.decorate(self)
|
23
|
-
end
|
24
|
-
|
25
18
|
private
|
26
19
|
|
27
20
|
# Sanitizes a nested hash. It removes leading underscores
|
data/lib/elastic_adapter.rb
CHANGED
@@ -8,6 +8,7 @@ require "elastic_adapter/decoration/count_response"
|
|
8
8
|
require "elastic_adapter/decoration/validation_response"
|
9
9
|
require "elastic_adapter/decoration/suggestion_response"
|
10
10
|
require "elastic_adapter/decoration/search_response"
|
11
|
+
require "elastic_adapter/decoration/aggregation_response"
|
11
12
|
require "elastic_adapter/decoration/response_decorator_factory"
|
12
13
|
require "elastic_adapter/response"
|
13
14
|
require "elastic_adapter/index"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:9200/test_index/_search
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"aggs":{"group":{"terms":{"field":"group"}}}}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=UTF-8
|
23
|
+
Content-Length:
|
24
|
+
- '483'
|
25
|
+
body:
|
26
|
+
encoding: UTF-8
|
27
|
+
string: '{"took":7,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"test_index","_type":"test_doc","_id":"AUv-oTm7Ngm7ooYjXOfD","_score":1.0,"_source":{"foo":"bar","group":"A"}},{"_index":"test_index","_type":"test_doc","_id":"AUv-n2n-Ngm7ooYjXOVX","_score":1.0,"_source":{"foo":"bar","group":"A"}}]},"aggregations":{"group":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[{"key":"a","doc_count":2}]}}}'
|
28
|
+
http_version:
|
29
|
+
recorded_at: Mon, 09 Mar 2015 13:02:38 GMT
|
30
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,84 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: http://localhost:9200/test_index
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"mappings":{"test_doc":{"properties":{"foo":{"type":"string"},"foo_suggest":{"type":"completion"}}}},"settings":{}}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 400
|
19
|
+
message: Bad Request
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=UTF-8
|
23
|
+
Content-Length:
|
24
|
+
- '81'
|
25
|
+
body:
|
26
|
+
encoding: UTF-8
|
27
|
+
string: '{"error":"IndexAlreadyExistsException[[test_index] already exists]","status":400}'
|
28
|
+
http_version:
|
29
|
+
recorded_at: Mon, 09 Mar 2015 13:02:33 GMT
|
30
|
+
- request:
|
31
|
+
method: post
|
32
|
+
uri: http://localhost:9200/test_index/test_doc
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '{"foo":"bar","group":"A"}'
|
36
|
+
headers:
|
37
|
+
User-Agent:
|
38
|
+
- Faraday v0.9.1
|
39
|
+
Accept-Encoding:
|
40
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
41
|
+
Accept:
|
42
|
+
- "*/*"
|
43
|
+
response:
|
44
|
+
status:
|
45
|
+
code: 201
|
46
|
+
message: Created
|
47
|
+
headers:
|
48
|
+
Content-Type:
|
49
|
+
- application/json; charset=UTF-8
|
50
|
+
Content-Length:
|
51
|
+
- '99'
|
52
|
+
body:
|
53
|
+
encoding: UTF-8
|
54
|
+
string: '{"_index":"test_index","_type":"test_doc","_id":"AUv-oTm7Ngm7ooYjXOfD","_version":1,"created":true}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Mon, 09 Mar 2015 13:02:33 GMT
|
57
|
+
- request:
|
58
|
+
method: delete
|
59
|
+
uri: http://localhost:9200/test_index
|
60
|
+
body:
|
61
|
+
encoding: US-ASCII
|
62
|
+
string: ''
|
63
|
+
headers:
|
64
|
+
User-Agent:
|
65
|
+
- Faraday v0.9.1
|
66
|
+
Accept-Encoding:
|
67
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
68
|
+
Accept:
|
69
|
+
- "*/*"
|
70
|
+
response:
|
71
|
+
status:
|
72
|
+
code: 200
|
73
|
+
message: OK
|
74
|
+
headers:
|
75
|
+
Content-Type:
|
76
|
+
- application/json; charset=UTF-8
|
77
|
+
Content-Length:
|
78
|
+
- '21'
|
79
|
+
body:
|
80
|
+
encoding: UTF-8
|
81
|
+
string: '{"acknowledged":true}'
|
82
|
+
http_version:
|
83
|
+
recorded_at: Mon, 09 Mar 2015 13:23:53 GMT
|
84
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module ElasticAdapter
|
4
|
+
module Decoration
|
5
|
+
describe AggregationResponse do
|
6
|
+
let(:response){{
|
7
|
+
aggregations: {
|
8
|
+
products: {
|
9
|
+
doc_count_error_upper_bound: 46,
|
10
|
+
buckets: [
|
11
|
+
{
|
12
|
+
key: "Product A",
|
13
|
+
doc_count: 100
|
14
|
+
},
|
15
|
+
{
|
16
|
+
key: "Product Z",
|
17
|
+
doc_count: 52
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}}
|
23
|
+
|
24
|
+
subject { AggregationResponse.new(response) }
|
25
|
+
|
26
|
+
describe "#aggregations" do
|
27
|
+
it "counts one" do
|
28
|
+
expect(subject.aggregations.count).to eq 1
|
29
|
+
end
|
30
|
+
|
31
|
+
it "contains products" do
|
32
|
+
expect(subject.aggregations).to have_key :products
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "products" do
|
36
|
+
it "counts two" do
|
37
|
+
expect(subject.aggregations[:products].count).to eq 2
|
38
|
+
end
|
39
|
+
|
40
|
+
it "contains Product A with it's count" do
|
41
|
+
expect(subject.aggregations[:products]).to include({
|
42
|
+
term: "Product A",
|
43
|
+
count: 100
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
47
|
+
it "contains Product Z with it's count" do
|
48
|
+
expect(subject.aggregations[:products]).to include({
|
49
|
+
term: "Product Z",
|
50
|
+
count: 52
|
51
|
+
})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -5,69 +5,72 @@ module ElasticAdapter
|
|
5
5
|
describe ResponseDecoratorFactory do
|
6
6
|
describe "class methods" do
|
7
7
|
describe "#decorate" do
|
8
|
-
context "
|
9
|
-
let(:response) {{ exception: ArgumentError.new }}
|
10
|
-
let(:subject) { ResponseDecoratorFactory.decorate(response)}
|
11
|
-
|
12
|
-
it "returns the unmodified response" do
|
13
|
-
expect(subject).to be response
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "response with acknowledged" do
|
8
|
+
context "count" do
|
18
9
|
let(:response) {{ acknowledged: true }}
|
19
|
-
|
10
|
+
subject { ResponseDecoratorFactory.decorate(response, :count) }
|
20
11
|
|
21
|
-
it "returns
|
22
|
-
expect(subject).to
|
12
|
+
it "returns a CountResponse" do
|
13
|
+
expect(subject).to be_a CountResponse
|
23
14
|
end
|
24
15
|
end
|
25
16
|
|
26
|
-
context "
|
17
|
+
context "hit" do
|
27
18
|
let(:response) {{ source: {} }}
|
28
|
-
|
19
|
+
subject { ResponseDecoratorFactory.decorate(response, :hit) }
|
29
20
|
|
30
21
|
it "returns a HitDecorator" do
|
31
22
|
expect(subject).to be_a HitDecorator
|
32
23
|
end
|
33
24
|
end
|
34
25
|
|
35
|
-
context "
|
26
|
+
context "search" do
|
36
27
|
let(:response) {{ hits: {hits: []} }}
|
37
|
-
|
28
|
+
subject { ResponseDecoratorFactory.decorate(response, :search) }
|
38
29
|
|
39
30
|
it "returns a SearchResponse" do
|
40
31
|
expect(subject).to be_a SearchResponse
|
41
32
|
end
|
42
33
|
end
|
43
34
|
|
44
|
-
context "
|
45
|
-
let(:response) {{
|
46
|
-
|
35
|
+
context "validation" do
|
36
|
+
let(:response) {{ valid: true }}
|
37
|
+
subject { ResponseDecoratorFactory.decorate(response, :validation) }
|
47
38
|
|
48
|
-
it "returns a
|
49
|
-
expect(subject).to be_a
|
39
|
+
it "returns a ValidationResponse" do
|
40
|
+
expect(subject).to be_a ValidationResponse
|
50
41
|
end
|
51
42
|
end
|
52
43
|
|
53
|
-
context "
|
44
|
+
context "suggestion" do
|
54
45
|
let(:response) {{ foo: "bar", foo_suggestion: [{options: []}] }}
|
55
|
-
|
46
|
+
subject { ResponseDecoratorFactory.decorate(response, :suggestion) }
|
56
47
|
|
57
48
|
it "returns a SuggestionResponse" do
|
58
49
|
expect(subject).to be_a SuggestionResponse
|
59
50
|
end
|
60
51
|
end
|
61
52
|
|
62
|
-
context "
|
63
|
-
let(:response)
|
64
|
-
|
53
|
+
context "aggregation" do
|
54
|
+
let(:response){{
|
55
|
+
aggregations: {
|
56
|
+
products: {
|
57
|
+
doc_count_error_upper_bound: 46,
|
58
|
+
buckets: [
|
59
|
+
{
|
60
|
+
key: "Product A",
|
61
|
+
doc_count: 100
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}}
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
subject { ResponseDecoratorFactory.decorate(response, :aggregation) }
|
69
|
+
|
70
|
+
it "returns a AggregationResponse" do
|
71
|
+
expect(subject).to be_a AggregationResponse
|
68
72
|
end
|
69
73
|
end
|
70
|
-
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "./shared_context.rb"
|
2
|
+
|
3
|
+
module ElasticAdapter
|
4
|
+
describe Index do
|
5
|
+
include_context "index context"
|
6
|
+
|
7
|
+
describe "#aggregate", :vcr do
|
8
|
+
before :all do
|
9
|
+
create_test_index
|
10
|
+
index_documents foo: "bar", group: "A"
|
11
|
+
index_documents foo: "baz", group: "A"
|
12
|
+
index_documents foo: "boo", group: "B"
|
13
|
+
end
|
14
|
+
|
15
|
+
after :all do
|
16
|
+
delete_test_index
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "response" do
|
20
|
+
let(:query) {{
|
21
|
+
aggs: {
|
22
|
+
group: {
|
23
|
+
terms: { field: "group" }
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}}
|
27
|
+
|
28
|
+
it "is a AggregationResponse" do
|
29
|
+
expect(subject.aggregate(query)).to be_a Decoration::AggregationResponse
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/response_spec.rb
CHANGED
@@ -32,6 +32,13 @@ module ElasticAdapter
|
|
32
32
|
response = Response.new(hash)
|
33
33
|
expect(response.object).to eq expected
|
34
34
|
end
|
35
|
+
|
36
|
+
it "works with arrays" do
|
37
|
+
hash = { "foo" => ["bar", "buz"] }
|
38
|
+
expected = { foo: ["bar", "buz"] }
|
39
|
+
response = Response.new(hash)
|
40
|
+
expect(response.object).to eq expected
|
41
|
+
end
|
35
42
|
end
|
36
43
|
|
37
44
|
describe "#failure?" do
|
@@ -53,28 +60,5 @@ module ElasticAdapter
|
|
53
60
|
end
|
54
61
|
end
|
55
62
|
end
|
56
|
-
|
57
|
-
describe "#decorate" do
|
58
|
-
context "find request" do
|
59
|
-
let(:document) { {foo: "bar", id: 1} }
|
60
|
-
let(:response_hash) do
|
61
|
-
{
|
62
|
-
"found" => true,
|
63
|
-
"_id" => 1,
|
64
|
-
"_source" => {
|
65
|
-
"foo" => "bar"
|
66
|
-
}
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
let(:response) do
|
71
|
-
response = Response.new(response_hash)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "is the document" do
|
75
|
-
expect(response.decorate.to_hash).to eq document
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
63
|
end
|
80
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristopher Bredemeier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -154,9 +154,9 @@ files:
|
|
154
154
|
- README.md
|
155
155
|
- Rakefile
|
156
156
|
- elastic_adapter.gemspec
|
157
|
-
- example.env
|
158
157
|
- examples/basic_usage.rb
|
159
158
|
- lib/elastic_adapter.rb
|
159
|
+
- lib/elastic_adapter/decoration/aggregation_response.rb
|
160
160
|
- lib/elastic_adapter/decoration/count_response.rb
|
161
161
|
- lib/elastic_adapter/decoration/decorator.rb
|
162
162
|
- lib/elastic_adapter/decoration/hit_decorator.rb
|
@@ -168,6 +168,8 @@ files:
|
|
168
168
|
- lib/elastic_adapter/index.rb
|
169
169
|
- lib/elastic_adapter/response.rb
|
170
170
|
- lib/elastic_adapter/version.rb
|
171
|
+
- spec/cassettes/ElasticAdapter_Index/_aggregate.yml
|
172
|
+
- spec/cassettes/ElasticAdapter_Index/_aggregate/response/is_a_AggregationResponse.yml
|
171
173
|
- spec/cassettes/ElasticAdapter_Index/_count/empty_index.yml
|
172
174
|
- spec/cassettes/ElasticAdapter_Index/_count/empty_index/is_a_response.yml
|
173
175
|
- spec/cassettes/ElasticAdapter_Index/_count/empty_index/returns_the_amount_of_all_documents.yml
|
@@ -207,9 +209,11 @@ files:
|
|
207
209
|
- spec/cassettes/ElasticAdapter_Index/_validate/invalid_query/is_false.yml
|
208
210
|
- spec/cassettes/ElasticAdapter_Index/_validate/valid_query/is_a_response.yml
|
209
211
|
- spec/cassettes/ElasticAdapter_Index/_validate/valid_query/is_true.yml
|
212
|
+
- spec/decoration/aggregation_response_spec.rb
|
210
213
|
- spec/decoration/response_decorator_factory_spec.rb
|
211
214
|
- spec/document_type_spec.rb
|
212
215
|
- spec/elastic_adapter_spec.rb
|
216
|
+
- spec/index/aggregation_spec.rb
|
213
217
|
- spec/index/count_spec.rb
|
214
218
|
- spec/index/create_index_spec.rb
|
215
219
|
- spec/index/delete_index_spec.rb
|
@@ -224,7 +228,7 @@ files:
|
|
224
228
|
- spec/response_spec.rb
|
225
229
|
- spec/spec_helper.rb
|
226
230
|
- spec/support/index_helper.rb
|
227
|
-
homepage: https://github.com/kbredemeier/
|
231
|
+
homepage: https://github.com/kbredemeier/elastic_adapter
|
228
232
|
licenses:
|
229
233
|
- MIT
|
230
234
|
metadata: {}
|
@@ -249,6 +253,8 @@ signing_key:
|
|
249
253
|
specification_version: 4
|
250
254
|
summary: Repository like access to elasticseach indices
|
251
255
|
test_files:
|
256
|
+
- spec/cassettes/ElasticAdapter_Index/_aggregate.yml
|
257
|
+
- spec/cassettes/ElasticAdapter_Index/_aggregate/response/is_a_AggregationResponse.yml
|
252
258
|
- spec/cassettes/ElasticAdapter_Index/_count/empty_index.yml
|
253
259
|
- spec/cassettes/ElasticAdapter_Index/_count/empty_index/is_a_response.yml
|
254
260
|
- spec/cassettes/ElasticAdapter_Index/_count/empty_index/returns_the_amount_of_all_documents.yml
|
@@ -288,9 +294,11 @@ test_files:
|
|
288
294
|
- spec/cassettes/ElasticAdapter_Index/_validate/invalid_query/is_false.yml
|
289
295
|
- spec/cassettes/ElasticAdapter_Index/_validate/valid_query/is_a_response.yml
|
290
296
|
- spec/cassettes/ElasticAdapter_Index/_validate/valid_query/is_true.yml
|
297
|
+
- spec/decoration/aggregation_response_spec.rb
|
291
298
|
- spec/decoration/response_decorator_factory_spec.rb
|
292
299
|
- spec/document_type_spec.rb
|
293
300
|
- spec/elastic_adapter_spec.rb
|
301
|
+
- spec/index/aggregation_spec.rb
|
294
302
|
- spec/index/count_spec.rb
|
295
303
|
- spec/index/create_index_spec.rb
|
296
304
|
- spec/index/delete_index_spec.rb
|
data/example.env
DELETED