arelastic 2.1.3 → 2.1.4

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
  SHA256:
3
- metadata.gz: 585b761da2b68ccf4cbca2a5a5a157e657ee3f1c40eced165e37ba516becb71d
4
- data.tar.gz: f6bb0160c6465adf9b6500c7a74e8a856d996be8e4cc14ea9e22b1d4f5a77f93
3
+ metadata.gz: d7dd07c79d390e3b2c840edaa9a075901818e0db63f9445b9df8be621a3f9128
4
+ data.tar.gz: 0fcccd8fb4fa7c24d76749986a65a20697bb51d93992c90d2e4b37d3dbfeec32
5
5
  SHA512:
6
- metadata.gz: a2c2a19e833bc6fe9b31207d0483150292ba35810da42a71f6e840c84f3d3d64f35dc57ab7b111bfacd9a2026bff9b976dfbb1851e5db5744191eb1d64a68fe6
7
- data.tar.gz: 4143b50ba43d950ff97c433638d4efd9da6015a4d9ca6704de6c22790d1bbe84237f46cd1fc3ca1460739f98fe9bc347b3471064593567c66cb3b6df9a791032
6
+ metadata.gz: 72836ec160d987f8fc5d648c0b2f82f10bc9c92e3b16ed002f8c9be189e3566aed31869f9f9c6f47bebd3507457415b50851af6371279abe9e86f82b0ac519c7
7
+ data.tar.gz: e1f8e296c26dacb529cd14858e06a2e69cd98af08261b3f62fe88c76bb86b0d46234145585925e7d30e72fa9ea23e98441d1cbac4d0121731dbe76dd51826868
@@ -0,0 +1,13 @@
1
+ module Arelastic
2
+ module Aggregations
3
+ class Sampler < Bucket
4
+ def initialize(name, shard_size, aggs)
5
+ super(name, aggs: aggs, shard_size: shard_size)
6
+ end
7
+
8
+ def as_elastic_aggregation
9
+ { 'sampler' => { 'shard_size' => options[:shard_size] } }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -6,4 +6,5 @@ require 'arelastic/aggregations/filter'
6
6
  require 'arelastic/aggregations/min'
7
7
  require 'arelastic/aggregations/nested'
8
8
  require 'arelastic/aggregations/reverse_nested'
9
+ require 'arelastic/aggregations/sampler'
9
10
  require 'arelastic/aggregations/terms'
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ class Arelastic::Aggregations::SamplerTest < Minitest::Test
4
+ def test_as_elastic
5
+ aggregation = Arelastic::Aggregations::Sampler.new('sample', 10, [
6
+ Arelastic::Aggregations::Terms.new('colors', 'field' => 'color')
7
+ ])
8
+
9
+ expected = {
10
+ 'sample' => {
11
+ 'sampler' => {
12
+ 'shard_size' => 10
13
+ },
14
+ 'aggs' => {
15
+ 'colors' => {
16
+ 'terms' => {
17
+ 'field' => 'color'
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ assert_equal expected, aggregation.as_elastic
24
+ end
25
+ end
@@ -1,10 +1,10 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::MatchAllTest < Minitest::Test
3
+ class Arelastic::Queries::MatchNoneTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  match_all = Arelastic::Queries::MatchNone.new
6
6
 
7
7
  expected = {"match_none" => {}}
8
8
  assert_equal expected, match_all.as_elastic
9
9
  end
10
- end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arelastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Higgins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build Elastic Search queries with objects
14
14
  email: developer@matthewhiggins.com
@@ -28,6 +28,7 @@ files:
28
28
  - lib/arelastic/aggregations/min.rb
29
29
  - lib/arelastic/aggregations/nested.rb
30
30
  - lib/arelastic/aggregations/reverse_nested.rb
31
+ - lib/arelastic/aggregations/sampler.rb
31
32
  - lib/arelastic/aggregations/terms.rb
32
33
  - lib/arelastic/arities.rb
33
34
  - lib/arelastic/arities/binary.rb
@@ -100,6 +101,7 @@ files:
100
101
  - test/arelastic/aggregations/filter_test.rb
101
102
  - test/arelastic/aggregations/nested_test.rb
102
103
  - test/arelastic/aggregations/reverse_nested_test.rb
104
+ - test/arelastic/aggregations/sampler_test.rb
103
105
  - test/arelastic/aggregations/terms_test.rb
104
106
  - test/arelastic/arities/binary_test.rb
105
107
  - test/arelastic/arities/polyadic_test.rb