elasticated 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/elasticated/aggregations/date_histogram_aggregation.rb +1 -6
- data/lib/elasticated/aggregations/safe_date_histogram_aggregation.rb +1 -6
- data/lib/elasticated/delimiters/date_field_delimiter.rb +6 -2
- data/lib/version.rb +10 -1
- data/spec/aggregation_spec.rb +6 -0
- data/spec/date_field_delimiter_spec.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdd5d2086175d504907b22b0b152d8adffa9e13b
|
4
|
+
data.tar.gz: 9db1e94f8ec716696ae2bb15cd1a3aa9878a030a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24bf04a0195e2e0d5db22df845cfd4f4506c53e72a4878a2b72cfea06b92da6d92f0455c449240708838e59bad2f3b68a2b5f7d7714e39f4cc5da1d0579f94f
|
7
|
+
data.tar.gz: da184d8c17afa3675989cfb244eb047ad4d8e14f24d9f23db2892f536784908607430071b6404fe13bba79ffc32ab8743b35320ed47d90f01c2d2c7be1a66fd5
|
@@ -2,21 +2,16 @@ module Elasticated
|
|
2
2
|
class DateHistogramAggregation < HistogramAggregation
|
3
3
|
include Subaggregated
|
4
4
|
|
5
|
-
attr_accessor :format
|
5
|
+
attr_accessor :format
|
6
6
|
|
7
7
|
def initialize(field, opts={}, &block)
|
8
8
|
self.format = opts.delete(:format) || 'yyyy-MM-dd'
|
9
9
|
interval = opts.delete(:interval) || 'day'
|
10
|
-
self.offset = opts.delete(:offset)
|
11
10
|
super field, interval, opts, &block
|
12
11
|
end
|
13
12
|
|
14
13
|
def build
|
15
14
|
terms = { field: field, interval: interval, format: format }
|
16
|
-
if offset # '1.4 style'
|
17
|
-
terms.merge! pre_offset: offset
|
18
|
-
terms.merge! post_offset: offset
|
19
|
-
end
|
20
15
|
terms.merge! extra_params
|
21
16
|
aggregation_struct = { date_histogram: terms }
|
22
17
|
aggregation_struct.merge! build_subaggregations
|
@@ -4,10 +4,9 @@ module Elasticated
|
|
4
4
|
|
5
5
|
DEFAULT_INTERVAL = '1d'
|
6
6
|
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :time_zone, :points, :compact, :include_count
|
8
8
|
|
9
9
|
def initialize(field, opts={}, &block)
|
10
|
-
self.offset = opts.delete(:offset)
|
11
10
|
self.time_zone = opts.delete(:time_zone)
|
12
11
|
self.points = opts.fetch(:points)
|
13
12
|
opts.delete(:points)
|
@@ -19,10 +18,6 @@ module Elasticated
|
|
19
18
|
|
20
19
|
def build
|
21
20
|
terms = { field: field, interval: safe_interval.to_s }
|
22
|
-
if offset # '1.4 style'
|
23
|
-
terms.merge! pre_offset: offset
|
24
|
-
terms.merge! post_offset: offset
|
25
|
-
end
|
26
21
|
if time_zone
|
27
22
|
terms.merge! time_zone: time_zone
|
28
23
|
end
|
@@ -24,8 +24,12 @@ module Elasticated
|
|
24
24
|
params.merge! date_since: date_since if date_since
|
25
25
|
params.merge! date_until: date_until if date_until
|
26
26
|
else
|
27
|
-
|
28
|
-
|
27
|
+
if values.count > 1
|
28
|
+
params.merge! date_since: values.min
|
29
|
+
params.merge! date_until: values.max
|
30
|
+
else
|
31
|
+
params.merge! date: values.first
|
32
|
+
end
|
29
33
|
end
|
30
34
|
params
|
31
35
|
end
|
data/lib/version.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
module Elasticated
|
2
|
-
VERSION = '3.0.
|
2
|
+
VERSION = '3.0.1'
|
3
3
|
end
|
4
4
|
|
5
5
|
# Changelog
|
6
6
|
|
7
|
+
# 3.0.1
|
8
|
+
|
9
|
+
# Cambios introducidos en 2.3.0
|
10
|
+
|
11
|
+
# 3.0.0
|
12
|
+
|
7
13
|
# Ahora Repository#execute_aggregated_search puede definir automaticamente si ejecutar las aggregations o no
|
8
14
|
# Se agrega el alias 'range' para la condicion 'between'
|
9
15
|
# Se agrega el alias 'terms' para la condicion 'equal'
|
@@ -22,6 +28,9 @@ end
|
|
22
28
|
# Se agrega TermCondition
|
23
29
|
# Ahora se puede especificar si el mapping es dinamico
|
24
30
|
|
31
|
+
# 2.3.0
|
32
|
+
# Ahora DateFieldDelimiter admite multiples fechas declaradas en un TermsCondition
|
33
|
+
|
25
34
|
# 2.2.0
|
26
35
|
# Se agrega la funcionalidad para especificar un orden aleatorio en las queries
|
27
36
|
|
data/spec/aggregation_spec.rb
CHANGED
@@ -275,6 +275,12 @@ module Elasticated
|
|
275
275
|
expect(agg.build).to eq expected_result
|
276
276
|
end
|
277
277
|
|
278
|
+
it "should build a date histogram aggregation with offset for date" do
|
279
|
+
agg = DateHistogramAggregation.new :date, offset: '+6h'
|
280
|
+
expected_result = { date_histogram: { field: :date, interval: 'day', format: 'yyyy-MM-dd', offset: '+6h' } }
|
281
|
+
expect(agg.build).to eq expected_result
|
282
|
+
end
|
283
|
+
|
278
284
|
it "should build a date histogram aggregation with subaggregations" do
|
279
285
|
agg = DateHistogramAggregation.new :date do |docs|
|
280
286
|
docs.max :numeric_field
|
@@ -19,10 +19,12 @@ module Elasticated
|
|
19
19
|
expect(params).to eq date: '2016-07-19'
|
20
20
|
end
|
21
21
|
|
22
|
-
it "should
|
23
|
-
delimiter.add_term :created_at, '
|
24
|
-
delimiter.add_term :created_at, '
|
25
|
-
|
22
|
+
it "should delimit by multiple terms" do
|
23
|
+
delimiter.add_term :created_at, '2017-03-30'
|
24
|
+
delimiter.add_term :created_at, '2017-03-25'
|
25
|
+
delimiter.add_term :created_at, '2017-03-27'
|
26
|
+
params = delimiter.build_strategy_params
|
27
|
+
expect(params).to eq date_since: '2017-03-25', date_until: '2017-03-30'
|
26
28
|
end
|
27
29
|
|
28
30
|
it "should delimit by a min date" do
|
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: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Fernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|