elastic-rails 0.6.3 → 0.6.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 +4 -4
- data/lib/elastic/commands/build_query_from_params.rb +17 -11
- data/lib/elastic/dsl/bool_query_builder.rb +6 -3
- data/lib/elastic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b9bacfe2ed32b87930002d60d7f84d8c996c05
|
4
|
+
data.tar.gz: e2d4f108fb27db7ec85afdb861f35a009db2db0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 425e22896f8f062c17dd12ead7ec8f052cf3e6a0151c71c788cc55636f3a3db2351e1a4af8bf6af87b3a7441f13c65ebecef0da7925baac0ddc709aeceffa632
|
7
|
+
data.tar.gz: 9e95d2d6e6ba9d85ae68ad88e241d61ba2558d45e20e1c939006eae783c8c7041f095eb18e2f9dc561f29a6271e7a5430188c252eaa9d81166f770338799212e
|
@@ -7,33 +7,39 @@ module Elastic::Commands
|
|
7
7
|
node = build_or_node(params)
|
8
8
|
end
|
9
9
|
|
10
|
-
node.simplify
|
10
|
+
node.try(:simplify)
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def build_or_node(_array)
|
16
|
-
|
16
|
+
parts = _array.map do |part|
|
17
17
|
case part
|
18
|
-
when Elastic::Query
|
19
|
-
extract_query_node part
|
20
18
|
when Hash
|
21
19
|
build_and_node part
|
20
|
+
when Elastic::Query
|
21
|
+
extract_query_node part
|
22
22
|
else
|
23
23
|
raise ArgumentError, "expected hash or query but got #{part.class}"
|
24
24
|
end
|
25
|
-
end)
|
26
|
-
end
|
25
|
+
end.reject(&:nil?)
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
_query.as_query_node
|
27
|
+
return nil if parts.empty?
|
28
|
+
Elastic::Nodes::Boolean.build_or(parts)
|
31
29
|
end
|
32
30
|
|
33
31
|
def build_and_node(_hash)
|
34
|
-
|
32
|
+
parts = _hash.map do |field, options|
|
35
33
|
build_query_node field, options
|
36
|
-
end)
|
34
|
+
end.reject(&:nil?)
|
35
|
+
|
36
|
+
return nil if parts.empty?
|
37
|
+
Elastic::Nodes::Boolean.build_and(parts)
|
38
|
+
end
|
39
|
+
|
40
|
+
def extract_query_node(_query)
|
41
|
+
raise ArgumentError, "query type mismatch, expected #{index.class}" if _query.index != index
|
42
|
+
_query.as_query_node
|
37
43
|
end
|
38
44
|
|
39
45
|
def build_query_node(_field, _options)
|
@@ -6,19 +6,22 @@ module Elastic::Dsl
|
|
6
6
|
|
7
7
|
def must(*_queries)
|
8
8
|
with_bool_query do |query|
|
9
|
-
|
9
|
+
node = build_query_from_params(_queries)
|
10
|
+
query.must node unless node.nil?
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
def must_not(*_queries)
|
14
15
|
with_bool_query do |query|
|
15
|
-
|
16
|
+
node = build_query_from_params(_queries)
|
17
|
+
query.must_not node unless node.nil?
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
def should(*_queries)
|
20
22
|
with_bool_query do |query|
|
21
|
-
|
23
|
+
node = build_query_from_params(_queries)
|
24
|
+
query.should node unless node.nil?
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
data/lib/elastic/version.rb
CHANGED