elasticated 1.2.1 → 2.0.0
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 +123 -1
- data/elasticated.gemspec +1 -0
- data/lib/elasticated.rb +18 -3
- data/lib/elasticated/aggregations/filter_aggregation.rb +13 -6
- data/lib/elasticated/aggregations/geohash_grid_aggregation.rb +28 -0
- data/lib/elasticated/aggregations/group_aggregation.rb +16 -7
- data/lib/elasticated/aggregations/missing_aggregation.rb +34 -0
- data/lib/elasticated/aggregations/range_aggregation.rb +14 -5
- data/lib/elasticated/aggregations/safe_date_histogram_aggregation.rb +86 -0
- data/lib/elasticated/aggregations/single_value_aggregation.rb +7 -1
- data/lib/elasticated/aggregations/stats_aggregation.rb +13 -0
- data/lib/elasticated/aggregations/subaggregated.rb +10 -1
- data/lib/elasticated/aggregations/top_hits_aggregation.rb +2 -2
- data/lib/elasticated/aggregations/{count_distinct_aggregation.rb → value_count_aggregation.rb} +1 -1
- data/lib/elasticated/configurable.rb +13 -2
- data/lib/elasticated/configuration.rb +6 -0
- data/lib/elasticated/document.rb +2 -1
- data/lib/elasticated/helpers.rb +18 -0
- data/lib/elasticated/loggers/default_logger.rb +27 -0
- data/lib/elasticated/loggers/silent_logger.rb +27 -0
- data/lib/elasticated/query.rb +8 -0
- data/lib/elasticated/query_aggregations.rb +3 -4
- data/lib/elasticated/repository.rb +31 -30
- data/lib/elasticated/repository/intelligent_search.rb +46 -0
- data/lib/elasticated/repository/normal_search.rb +40 -0
- data/lib/elasticated/repository/resumable_search.rb +58 -0
- data/lib/elasticated/repository/scan_scroll_search.rb +43 -0
- data/lib/elasticated/repository/scroll_search.rb +45 -0
- data/lib/elasticated/repository/search.rb +45 -0
- data/lib/elasticated/repository/single_page_search.rb +13 -0
- data/lib/elasticated/results.rb +43 -25
- data/lib/version.rb +11 -1
- data/spec/aggregation_spec.rb +58 -32
- data/spec/document_spec.rb +4 -4
- data/spec/intelligent_search_spec.rb +88 -0
- data/spec/query_spec.rb +2 -2
- data/spec/results_spec.rb +9 -9
- metadata +38 -5
- data/lib/elasticated/aggregations/count_aggregation.rb +0 -15
- data/lib/elasticated/default_logger.rb +0 -27
data/spec/query_spec.rb
CHANGED
@@ -195,7 +195,7 @@ module Elasticated
|
|
195
195
|
end
|
196
196
|
q.aggregations do
|
197
197
|
group :entry_type, size: 5 do
|
198
|
-
|
198
|
+
group :entry_name, compact: true
|
199
199
|
end
|
200
200
|
end
|
201
201
|
q.size 20
|
@@ -244,7 +244,7 @@ module Elasticated
|
|
244
244
|
field: :entry_type, size: 5
|
245
245
|
},
|
246
246
|
aggs: {
|
247
|
-
|
247
|
+
group_by_entry_name: {
|
248
248
|
terms: {
|
249
249
|
field: :entry_name, size: 0
|
250
250
|
}
|
data/spec/results_spec.rb
CHANGED
@@ -9,7 +9,7 @@ module Elasticated
|
|
9
9
|
|
10
10
|
it "should parse an 'search' response" do
|
11
11
|
response = open_response 'elasticsearch_response_1'
|
12
|
-
results = Results.
|
12
|
+
results = Results.parse response
|
13
13
|
expect(results.took).to eq 106
|
14
14
|
expect(results.timed_out).to eq false
|
15
15
|
expect(results.shards.total).to eq 3
|
@@ -21,12 +21,12 @@ module Elasticated
|
|
21
21
|
expect(results.documents.first).to be_a Document
|
22
22
|
end
|
23
23
|
|
24
|
-
it "allow to access documents as an array" do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
24
|
+
# it "allow to access documents as an array" do
|
25
|
+
# response = open_response 'elasticsearch_response_1'
|
26
|
+
# results = Results.parse response
|
27
|
+
# expect(results).to be_an Array
|
28
|
+
# expect(results.count).to eq 1
|
29
|
+
# end
|
30
30
|
|
31
31
|
it "should parse an 'search_aggregated' response" do
|
32
32
|
response = open_response 'elasticsearch_response_2'
|
@@ -35,7 +35,7 @@ module Elasticated
|
|
35
35
|
nested('ads'){ group 'ads.adgroups', size: 1, as: 'group_by_adgroup' }
|
36
36
|
end
|
37
37
|
end
|
38
|
-
results = Results.
|
38
|
+
results = Results.parse response, query
|
39
39
|
expect(results.took).to eq 140
|
40
40
|
expect(results.timed_out).to eq false
|
41
41
|
expect(results.shards.total).to eq 3
|
@@ -52,7 +52,7 @@ module Elasticated
|
|
52
52
|
|
53
53
|
it "should not parse aggregations on an 'search_aggregated' response if no query is provided" do
|
54
54
|
response = open_response 'elasticsearch_response_2'
|
55
|
-
results = Results.
|
55
|
+
results = Results.parse response
|
56
56
|
expect(results.took).to eq 140
|
57
57
|
expect(results.timed_out).to eq false
|
58
58
|
expect(results.shards.total).to eq 3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Fernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,26 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.1.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: timing
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.0'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.0.9
|
107
|
+
type: :runtime
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0.0'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.0.9
|
97
117
|
description: ''
|
98
118
|
email:
|
99
119
|
- psfutn@gmail.com
|
@@ -109,24 +129,27 @@ files:
|
|
109
129
|
- lib/elasticated.rb
|
110
130
|
- lib/elasticated/aggregation.rb
|
111
131
|
- lib/elasticated/aggregations/cardinality_aggregation.rb
|
112
|
-
- lib/elasticated/aggregations/count_aggregation.rb
|
113
|
-
- lib/elasticated/aggregations/count_distinct_aggregation.rb
|
114
132
|
- lib/elasticated/aggregations/count_filtered_aggregation.rb
|
115
133
|
- lib/elasticated/aggregations/custom_aggregation.rb
|
116
134
|
- lib/elasticated/aggregations/date_histogram_aggregation.rb
|
117
135
|
- lib/elasticated/aggregations/filter_aggregation.rb
|
118
136
|
- lib/elasticated/aggregations/filter_aggregation_evaluator.rb
|
137
|
+
- lib/elasticated/aggregations/geohash_grid_aggregation.rb
|
119
138
|
- lib/elasticated/aggregations/group_aggregation.rb
|
120
139
|
- lib/elasticated/aggregations/histogram_aggregation.rb
|
140
|
+
- lib/elasticated/aggregations/missing_aggregation.rb
|
121
141
|
- lib/elasticated/aggregations/nested_aggregation.rb
|
122
142
|
- lib/elasticated/aggregations/range_aggregation.rb
|
123
143
|
- lib/elasticated/aggregations/range_aggregation_evaluator.rb
|
124
144
|
- lib/elasticated/aggregations/ranges_builder.rb
|
145
|
+
- lib/elasticated/aggregations/safe_date_histogram_aggregation.rb
|
125
146
|
- lib/elasticated/aggregations/single_value_aggregation.rb
|
147
|
+
- lib/elasticated/aggregations/stats_aggregation.rb
|
126
148
|
- lib/elasticated/aggregations/subaggregated.rb
|
127
149
|
- lib/elasticated/aggregations/sum_distinct_aggregation.rb
|
128
150
|
- lib/elasticated/aggregations/terms_aggregation.rb
|
129
151
|
- lib/elasticated/aggregations/top_hits_aggregation.rb
|
152
|
+
- lib/elasticated/aggregations/value_count_aggregation.rb
|
130
153
|
- lib/elasticated/block_evaluation.rb
|
131
154
|
- lib/elasticated/boolean_clause.rb
|
132
155
|
- lib/elasticated/client.rb
|
@@ -143,7 +166,6 @@ files:
|
|
143
166
|
- lib/elasticated/conditions_builder.rb
|
144
167
|
- lib/elasticated/configurable.rb
|
145
168
|
- lib/elasticated/configuration.rb
|
146
|
-
- lib/elasticated/default_logger.rb
|
147
169
|
- lib/elasticated/delimiters/date_field_delimiter.rb
|
148
170
|
- lib/elasticated/delimiters/standard_field_delimiter.rb
|
149
171
|
- lib/elasticated/delimiters/term_field_delimiter.rb
|
@@ -151,6 +173,8 @@ files:
|
|
151
173
|
- lib/elasticated/helpers.rb
|
152
174
|
- lib/elasticated/index_selector.rb
|
153
175
|
- lib/elasticated/inspectionable.rb
|
176
|
+
- lib/elasticated/loggers/default_logger.rb
|
177
|
+
- lib/elasticated/loggers/silent_logger.rb
|
154
178
|
- lib/elasticated/mapping.rb
|
155
179
|
- lib/elasticated/mapping/builder.rb
|
156
180
|
- lib/elasticated/mapping/fields_builder.rb
|
@@ -163,6 +187,13 @@ files:
|
|
163
187
|
- lib/elasticated/query_aggregations.rb
|
164
188
|
- lib/elasticated/query_conditions.rb
|
165
189
|
- lib/elasticated/repository.rb
|
190
|
+
- lib/elasticated/repository/intelligent_search.rb
|
191
|
+
- lib/elasticated/repository/normal_search.rb
|
192
|
+
- lib/elasticated/repository/resumable_search.rb
|
193
|
+
- lib/elasticated/repository/scan_scroll_search.rb
|
194
|
+
- lib/elasticated/repository/scroll_search.rb
|
195
|
+
- lib/elasticated/repository/search.rb
|
196
|
+
- lib/elasticated/repository/single_page_search.rb
|
166
197
|
- lib/elasticated/results.rb
|
167
198
|
- lib/version.rb
|
168
199
|
- spec/aggregation_spec.rb
|
@@ -173,6 +204,7 @@ files:
|
|
173
204
|
- spec/elasticsearch_response_2.json
|
174
205
|
- spec/elasticsearch_top_hits_response.json
|
175
206
|
- spec/integration_spec.rb
|
207
|
+
- spec/intelligent_search_spec.rb
|
176
208
|
- spec/mapping_spec.rb
|
177
209
|
- spec/query_aggregations_spec.rb
|
178
210
|
- spec/query_conditions_spec.rb
|
@@ -213,6 +245,7 @@ test_files:
|
|
213
245
|
- spec/elasticsearch_response_2.json
|
214
246
|
- spec/elasticsearch_top_hits_response.json
|
215
247
|
- spec/integration_spec.rb
|
248
|
+
- spec/intelligent_search_spec.rb
|
216
249
|
- spec/mapping_spec.rb
|
217
250
|
- spec/query_aggregations_spec.rb
|
218
251
|
- spec/query_conditions_spec.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Elasticated
|
2
|
-
class CountAggregation < TermsAggregation
|
3
|
-
|
4
|
-
def default_name
|
5
|
-
"count_by_#{field}"
|
6
|
-
end
|
7
|
-
|
8
|
-
def parse(response)
|
9
|
-
response['buckets'].inject({}) do |hash, bucket|
|
10
|
-
hash.merge bucket['key'] => bucket['doc_count']
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Elasticated
|
2
|
-
class DefaultLogger
|
3
|
-
|
4
|
-
# interface
|
5
|
-
|
6
|
-
def trace(message)
|
7
|
-
puts "TRACE #{message}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def debug(message)
|
11
|
-
puts "DEBUG #{message}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def info(message)
|
15
|
-
puts "INFO #{message}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def warn(message)
|
19
|
-
puts "WARN #{message}"
|
20
|
-
end
|
21
|
-
|
22
|
-
def error(message)
|
23
|
-
puts "ERROR #{message}"
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|