elasticsearch-dsl-builder 0.0.18 → 0.0.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cba0e34f4b2d5f08e57f37dce0099bb9e8252bab
4
- data.tar.gz: 3b03128a47a64c2d1270ff1c3d2b44fb7704217d
3
+ metadata.gz: 453e3fd5d3b0339d6706247ade41438347f1ca9c
4
+ data.tar.gz: 3989b7e9213782109d7bab0dcfb036dad90bf2a6
5
5
  SHA512:
6
- metadata.gz: 7a318bff127840356b34951fc156fe0c642c5dea9da4aca5140422e858f6c4dd43bfbdb449d45a0171b536cc923b42168a6260f214c8685379d2ff5c4571956d
7
- data.tar.gz: ebf0db9e17d50adb1615ed4157831073ace8866eadc75aaf8d215ec7884759d89a0d3739869017892068a0caf8cc18950321950fcfb77a6976d5cc69c8ce95d1
6
+ metadata.gz: d445152fffc6cdb0e32297981c3079143176367300ffd365d960d0c4ba98551778be22f5bc1acb1c3dffca3302a6c7b3d3c52370867c0d448071c7986220fd7e
7
+ data.tar.gz: 48b2b6efb27441b464867db62cbe8fde75a4fec39d91e628c1aaa0ba9152f0816a14c46a12882c2084cbd3492b2d563dd4e330bc700749dfb6da46fbaae83999
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elasticsearch-dsl-builder (0.0.18)
4
+ elasticsearch-dsl-builder (0.0.19)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'elasticsearch-dsl-builder'
3
- s.version = '0.0.18'
3
+ s.version = '0.0.19'
4
4
  s.date = '2017-10-06'
5
5
  s.summary = 'Library utilizing builder pattern providing Ruby API for the Elasticsearch Query DSL'
6
6
  s.description = 'TBD'
@@ -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').format('MM-yyy')
24
- expect(date_histogram.to_hash).to eq(date_histogram: { field: 'field_a', interval: 'month', format: 'MM-yyy' })
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-dsl-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Guerra