arelastic 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arelastic/queries.rb +1 -0
- data/lib/arelastic/queries/dis_max.rb +19 -0
- data/test/arelastic/queries/dis_max_test.rb +23 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93b2709cca3f4723d5f150393c9f6775a8b7cbcc
|
4
|
+
data.tar.gz: e5486609d6bc06427221f16934c654e4734251ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e487e432fee0ec87e3605e53fb31762afc997b3d70f7a462a7268a590903d8966d6cc65d5f45a68923097c856381e8f121cabf21288647cad9bafe074a0f73a5
|
7
|
+
data.tar.gz: 0fba9e18f025a42890305a02f5cffadc7c930c64f90b6bb86608529d53c785f533ffd3cfcc15ea03bd2c7a2bd06316f5c40a9e68e8a1ab7920f4da79d861f418
|
data/lib/arelastic/queries.rb
CHANGED
@@ -2,6 +2,7 @@ require 'arelastic/queries/query'
|
|
2
2
|
|
3
3
|
require 'arelastic/queries/bool'
|
4
4
|
require 'arelastic/queries/constant_score'
|
5
|
+
require 'arelastic/queries/dis_max'
|
5
6
|
require 'arelastic/queries/exists'
|
6
7
|
require 'arelastic/queries/field'
|
7
8
|
require 'arelastic/queries/geo_bounding_box'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Arelastic
|
2
|
+
module Queries
|
3
|
+
class DisMax < Arelastic::Queries::Query
|
4
|
+
attr_accessor :queries, :options
|
5
|
+
def initialize(options)
|
6
|
+
@queries = options.delete('queries') || options.delete(:queries)
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def as_elastic
|
11
|
+
{
|
12
|
+
"dis_max" => {
|
13
|
+
"queries" => convert_to_elastic(queries)
|
14
|
+
}.merge(options)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class Arelastic::Queries::DisMaxTest < Minitest::Test
|
4
|
+
def test_as_elastic
|
5
|
+
bool = Arelastic::Queries::DisMax.new(
|
6
|
+
queries: [
|
7
|
+
{'term' => {'user' => 'kimchy'}},
|
8
|
+
Arelastic::Queries::Match.new('color', 'green')
|
9
|
+
]
|
10
|
+
)
|
11
|
+
|
12
|
+
expected = {
|
13
|
+
'dis_max' => {
|
14
|
+
'queries' => [
|
15
|
+
{'term' => {'user'=>'kimchy'}},
|
16
|
+
{'match' =>{ 'color'=>'green'}}
|
17
|
+
]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
assert_equal expected, bool.as_elastic
|
22
|
+
end
|
23
|
+
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.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Higgins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build Elastic Search queries with objects
|
14
14
|
email: developer@matthewhiggins.com
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/arelastic/queries.rb
|
56
56
|
- lib/arelastic/queries/bool.rb
|
57
57
|
- lib/arelastic/queries/constant_score.rb
|
58
|
+
- lib/arelastic/queries/dis_max.rb
|
58
59
|
- lib/arelastic/queries/exists.rb
|
59
60
|
- lib/arelastic/queries/field.rb
|
60
61
|
- lib/arelastic/queries/filter.rb
|
@@ -111,6 +112,7 @@ files:
|
|
111
112
|
- test/arelastic/mappings/types/string_test.rb
|
112
113
|
- test/arelastic/nodes/node_test.rb
|
113
114
|
- test/arelastic/queries/bool_test.rb
|
115
|
+
- test/arelastic/queries/dis_max_test.rb
|
114
116
|
- test/arelastic/queries/exists_test.rb
|
115
117
|
- test/arelastic/queries/filter_test.rb
|
116
118
|
- test/arelastic/queries/geo_bounding_box_test.rb
|
@@ -152,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
154
|
version: 1.8.11
|
153
155
|
requirements: []
|
154
156
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.6.
|
157
|
+
rubygems_version: 2.6.11
|
156
158
|
signing_key:
|
157
159
|
specification_version: 4
|
158
160
|
summary: Elastic Search query builder
|