arelastic 2.4.3 → 2.5.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 +4 -4
- data/lib/arelastic/builders/query.rb +41 -33
- data/test/arelastic/builders/query_test.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7edbcecc9f2338f91c04f02153e5be31d1b31dbe0c3f2f8d8ae459a1390ff1c
|
|
4
|
+
data.tar.gz: ba5a7048b7602c5ac6a1ddbcd35578a14e81f46987665e2f2d3227bce69e3a8b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1243c2065fb4c6b33e0bba2396ea7306bc08210758ca4b974c25587f0d3bad552431c5c65b95af858385126fd6ddc621db2ee1286f0b16febae8fc4c7694196f
|
|
7
|
+
data.tar.gz: '0922d96e1247d446dc4acce1ea37f03229b06d85f213d4e1e8263590aeb6d3bc770c838e39a6b16a3ad404f3e41298fca3ce7560d6ce2e0e24134301e3d92a13'
|
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
module Arelastic
|
|
2
2
|
module Builders
|
|
3
3
|
class Query < Struct.new :name
|
|
4
|
+
MACROS_TO_ARELASTIC = {
|
|
5
|
+
bool: Arelastic::Queries::Bool,
|
|
6
|
+
constant_score: Arelastic::Queries::ConstantScore,
|
|
7
|
+
dis_max: Arelastic::Queries::DisMax,
|
|
8
|
+
exists: Arelastic::Queries::Exists,
|
|
9
|
+
field: Arelastic::Queries::Field,
|
|
10
|
+
filter: Arelastic::Queries::Filter,
|
|
11
|
+
function_score: Arelastic::Queries::FunctionScore,
|
|
12
|
+
fuzzy: Arelastic::Queries::Fuzzy,
|
|
13
|
+
geo_bounding_box: Arelastic::Queries::GeoBoundingBox,
|
|
14
|
+
geo_distance: Arelastic::Queries::GeoDistance,
|
|
15
|
+
has_child: Arelastic::Queries::HasChild,
|
|
16
|
+
ids: Arelastic::Queries::Ids,
|
|
17
|
+
limit: Arelastic::Queries::Limit,
|
|
18
|
+
match: Arelastic::Queries::Match,
|
|
19
|
+
match_all: Arelastic::Queries::MatchAll,
|
|
20
|
+
match_none: Arelastic::Queries::MatchNone,
|
|
21
|
+
match_phrase: Arelastic::Queries::MatchPhrase,
|
|
22
|
+
multi_match: Arelastic::Queries::MultiMatch,
|
|
23
|
+
nested: Arelastic::Queries::Nested,
|
|
24
|
+
percolate: Arelastic::Queries::Percolate,
|
|
25
|
+
prefix: Arelastic::Queries::Prefix,
|
|
26
|
+
query: Arelastic::Queries::Query,
|
|
27
|
+
query_string: Arelastic::Queries::QueryString,
|
|
28
|
+
range: Arelastic::Queries::Range,
|
|
29
|
+
regexp: Arelastic::Queries::Regexp,
|
|
30
|
+
script: Arelastic::Queries::Script,
|
|
31
|
+
simple_query_string: Arelastic::Queries::SimpleQueryString,
|
|
32
|
+
term: Arelastic::Queries::Term,
|
|
33
|
+
terms: Arelastic::Queries::Terms,
|
|
34
|
+
wildcard: Arelastic::Queries::Wildcard
|
|
35
|
+
}
|
|
36
|
+
|
|
4
37
|
class << self
|
|
5
38
|
def [](field)
|
|
6
39
|
new(field)
|
|
7
40
|
end
|
|
8
41
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def bool(must: nil, filter: nil, should: nil, must_not: nil)
|
|
14
|
-
query Arelastic::Queries::Bool.new(must: must, filter: filter, should: should, must_not: must_not)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def match_all
|
|
18
|
-
query Arelastic::Queries::MatchAll.new
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def multi_match(query, fields, options = {})
|
|
22
|
-
query Arelastic::Queries::MultiMatch.new query, fields, options
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
def query value
|
|
27
|
-
Arelastic::Searches::Query.new value
|
|
42
|
+
MACROS_TO_ARELASTIC.each do |macro, klass|
|
|
43
|
+
define_method macro do |*args|
|
|
44
|
+
klass.new(*args)
|
|
28
45
|
end
|
|
46
|
+
end
|
|
29
47
|
end
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def term other
|
|
36
|
-
Arelastic::Queries::Term.new name, other
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def terms other
|
|
40
|
-
Arelastic::Queries::Terms.new name, other
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def match other
|
|
44
|
-
Arelastic::Queries::Match.new name, other
|
|
49
|
+
MACROS_TO_ARELASTIC.each do |macro, klass|
|
|
50
|
+
define_method macro do |*args|
|
|
51
|
+
klass.new(name, *args)
|
|
52
|
+
end
|
|
45
53
|
end
|
|
46
54
|
end
|
|
47
55
|
end
|
|
@@ -3,7 +3,7 @@ require 'helper'
|
|
|
3
3
|
class Arelastic::Builders::QueryTest < Minitest::Test
|
|
4
4
|
def test_constant_score
|
|
5
5
|
query = Arelastic::Builders::Query.constant_score({"foo" => "bar"})
|
|
6
|
-
expected = {"
|
|
6
|
+
expected = {"constant_score" => {"foo" => "bar"}}
|
|
7
7
|
|
|
8
8
|
assert_equal expected, query.as_elastic
|
|
9
9
|
end
|
|
@@ -13,14 +13,14 @@ class Arelastic::Builders::QueryTest < Minitest::Test
|
|
|
13
13
|
must: {"query_string" => "foo"},
|
|
14
14
|
filter: {"term" => "bar"}
|
|
15
15
|
)
|
|
16
|
-
expected = {"
|
|
16
|
+
expected = {"bool" => {"must" => {"query_string" => "foo"}, "filter" => {"term" => "bar"}}}
|
|
17
17
|
|
|
18
18
|
assert_equal expected, query.as_elastic
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def test_match_all
|
|
22
22
|
query = Arelastic::Builders::Query.match_all
|
|
23
|
-
expected = {"
|
|
23
|
+
expected = {"match_all" => {}}
|
|
24
24
|
|
|
25
25
|
assert_equal expected, query.as_elastic
|
|
26
26
|
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.5.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-11-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Build Elastic Search queries with objects
|
|
14
14
|
email: developer@matthewhiggins.com
|
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
170
170
|
version: '0'
|
|
171
171
|
requirements: []
|
|
172
172
|
rubyforge_project:
|
|
173
|
-
rubygems_version: 2.7.
|
|
173
|
+
rubygems_version: 2.7.8
|
|
174
174
|
signing_key:
|
|
175
175
|
specification_version: 4
|
|
176
176
|
summary: Elastic Search query builder
|