elasticsearch-dsl-builder 0.0.18 → 0.0.19
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: 453e3fd5d3b0339d6706247ade41438347f1ca9c
|
4
|
+
data.tar.gz: 3989b7e9213782109d7bab0dcfb036dad90bf2a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d445152fffc6cdb0e32297981c3079143176367300ffd365d960d0c4ba98551778be22f5bc1acb1c3dffca3302a6c7b3d3c52370867c0d448071c7986220fd7e
|
7
|
+
data.tar.gz: 48b2b6efb27441b464867db62cbe8fde75a4fec39d91e628c1aaa0ba9152f0816a14c46a12882c2084cbd3492b2d563dd4e330bc700749dfb6da46fbaae83999
|
data/Gemfile.lock
CHANGED
@@ -28,9 +28,31 @@ module ElasticsearchDslBuilder
|
|
28
28
|
self
|
29
29
|
end
|
30
30
|
|
31
|
+
def min_doc_count(min)
|
32
|
+
raise ArgumentError, 'min_doc_count must be Numeric' unless min.is_a?(Numeric)
|
33
|
+
@min_doc_count = min
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def extended_bounds_min(min)
|
38
|
+
@extended_bounds_min = min
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def extended_bounds_max(max)
|
43
|
+
@extended_bounds_max = max
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
31
47
|
def to_hash
|
32
48
|
@aggregation = { field: @field, interval: @interval }
|
33
49
|
@aggregation.update(format: @format) if @format
|
50
|
+
@aggregation.update(min_doc_count: @min_doc_count) if @min_doc_count
|
51
|
+
|
52
|
+
extended_bounds = {}
|
53
|
+
extended_bounds.update(min: @extended_bounds_min) if @extended_bounds_min
|
54
|
+
extended_bounds.update(max: @extended_bounds_max) if @extended_bounds_max
|
55
|
+
@aggregation.update(extended_bounds: extended_bounds) unless extended_bounds.empty?
|
34
56
|
super
|
35
57
|
end
|
36
58
|
end
|
@@ -19,8 +19,18 @@ describe ElasticsearchDslBuilder::DSL::Search::Aggregations::DateHistogram do
|
|
19
19
|
expect { Aggregations::DateHistogram.new('field_a').format(nil) }.to raise_error(ArgumentError)
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'should fail if min_doc_count not valid' do
|
23
|
+
expect { Aggregations::DateHistogram.new('field_a').min_doc_count('fail') }.to raise_error(ArgumentError)
|
24
|
+
expect { Aggregations::DateHistogram.new('field_a').min_doc_count(nil) }.to raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
|
22
27
|
it 'should chain create valid ES aggregation hash' do
|
23
|
-
date_histogram = Aggregations::DateHistogram.new('field_a', 'month').
|
24
|
-
|
28
|
+
date_histogram = Aggregations::DateHistogram.new('field_a', 'month').
|
29
|
+
format('MM-yyy').extended_bounds_min(10).extended_bounds_max(15).min_doc_count(0)
|
30
|
+
expect(date_histogram.to_hash).to eq(
|
31
|
+
date_histogram: {
|
32
|
+
field: 'field_a', interval: 'month', format: 'MM-yyy', min_doc_count: 0, extended_bounds: { min: 10, max: 15 }
|
33
|
+
}
|
34
|
+
)
|
25
35
|
end
|
26
36
|
end
|