arelastic 2.3.1 → 2.4.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef3b1158d5db01fba4396abb65ef1e2aa54bdd25282136ab10a3b8e3abf3be9e
|
4
|
+
data.tar.gz: 80bdddc3f1f37e3568f56f204f272649edbd03470f44dbff77081e8263e36c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7e5caf0cf662e3cffb03b07485a73fe5fcfc49e49b1d93377858df81fbb22d5002f91f409b0ea65d9b37e5343c399387367b6db6fc6bcf95d1cfb35b64147e
|
7
|
+
data.tar.gz: b85604fb9a3165447112476b72895bef64a583c689668df2707dedecd733f40156314a2fd3bb654a026fc1e02891e2bea0b07720ab00defa36b646a7668413ec
|
@@ -3,6 +3,7 @@ require 'arelastic/aggregations/bucket'
|
|
3
3
|
|
4
4
|
require 'arelastic/aggregations/date_histogram'
|
5
5
|
require 'arelastic/aggregations/filter'
|
6
|
+
require 'arelastic/aggregations/filters'
|
6
7
|
require 'arelastic/aggregations/histogram'
|
7
8
|
require 'arelastic/aggregations/min'
|
8
9
|
require 'arelastic/aggregations/missing'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Arelastic
|
2
|
+
module Aggregations
|
3
|
+
class Filters < Arelastic::Aggregations::Bucket
|
4
|
+
attr_accessor :filters
|
5
|
+
|
6
|
+
def initialize(name, filters, options = {})
|
7
|
+
super name, options
|
8
|
+
@filters = filters
|
9
|
+
end
|
10
|
+
|
11
|
+
def as_elastic_aggregation
|
12
|
+
{'filters' => convert_to_elastic(filters)}.merge(super)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/arelastic/nodes/node.rb
CHANGED
@@ -8,6 +8,8 @@ module Arelastic
|
|
8
8
|
def convert_to_elastic(expr)
|
9
9
|
if expr.is_a?(Array)
|
10
10
|
expr.map { |e| convert_to_elastic(e) }
|
11
|
+
elsif expr.is_a?(Hash)
|
12
|
+
expr.transform_values { |e| convert_to_elastic(e) }
|
11
13
|
else
|
12
14
|
expr.respond_to?(:as_elastic) ? expr.as_elastic : expr
|
13
15
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class Arelastic::Aggregations::FiltersTest < Minitest::Test
|
4
|
+
def test_as_elastic_with_array
|
5
|
+
aggregation = Arelastic::Aggregations::Filters.new 'foo', [
|
6
|
+
{'exists' => {'field' => 'color'}},
|
7
|
+
Arelastic::Queries::Exists.new('price')
|
8
|
+
]
|
9
|
+
|
10
|
+
expected = {
|
11
|
+
"foo" => {
|
12
|
+
"filters" => [
|
13
|
+
{
|
14
|
+
"exists" => {
|
15
|
+
"field" => "color"
|
16
|
+
},
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"exists" => {
|
20
|
+
"field" => "price"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
assert_equal expected, aggregation.as_elastic
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_as_elastic_with_hash
|
31
|
+
aggregation = Arelastic::Aggregations::Filters.new 'foo', {
|
32
|
+
'color_count' => {'exists' => {'field' => 'color'}},
|
33
|
+
'price_count' => Arelastic::Queries::Exists.new('price')
|
34
|
+
}
|
35
|
+
|
36
|
+
expected = {
|
37
|
+
"foo" => {
|
38
|
+
"filters" => {
|
39
|
+
"color_count" => {
|
40
|
+
"exists" => {
|
41
|
+
"field" => "color"
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"price_count" => {
|
45
|
+
"exists" => {
|
46
|
+
"field" => "price"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
assert_equal expected, aggregation.as_elastic
|
54
|
+
end
|
55
|
+
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.
|
4
|
+
version: 2.4.0
|
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-
|
11
|
+
date: 2018-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build Elastic Search queries with objects
|
14
14
|
email: developer@matthewhiggins.com
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- lib/arelastic/aggregations/bucket.rb
|
25
25
|
- lib/arelastic/aggregations/date_histogram.rb
|
26
26
|
- lib/arelastic/aggregations/filter.rb
|
27
|
+
- lib/arelastic/aggregations/filters.rb
|
27
28
|
- lib/arelastic/aggregations/histogram.rb
|
28
29
|
- lib/arelastic/aggregations/min.rb
|
29
30
|
- lib/arelastic/aggregations/missing.rb
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- test/arelastic/aggregations/bucket_test.rb
|
102
103
|
- test/arelastic/aggregations/date_histogram_test.rb
|
103
104
|
- test/arelastic/aggregations/filter_test.rb
|
105
|
+
- test/arelastic/aggregations/filters_test.rb
|
104
106
|
- test/arelastic/aggregations/missing_test.rb
|
105
107
|
- test/arelastic/aggregations/nested_test.rb
|
106
108
|
- test/arelastic/aggregations/range_test.rb
|