arelastic 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 461f0c1c4638378978028848fa4b076be47c2e2f
|
4
|
+
data.tar.gz: 08a45801e8a532840076b49315029a4984ba0632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d59ba50365fb2902826794e215114d6c28b93d1772328aba566ff18921665f83ec76865863febdda8a7d5e6c0b173a98af2e2cc30e5bdbf68113997c829567
|
7
|
+
data.tar.gz: 6c6d9e6b38e7d1717a50a1850aa94f8d4796434f7ada756deaf380e9830093a0a8135fc13aafea999571283f3bdc56d4bc13495a9b93c3cc933224cf41fa0753
|
data/lib/arelastic/nodes/node.rb
CHANGED
@@ -6,7 +6,11 @@ module Arelastic
|
|
6
6
|
extend Arelastic::Arities::Unary
|
7
7
|
|
8
8
|
def convert_to_elastic(expr)
|
9
|
-
expr.
|
9
|
+
if expr.is_a?(Array)
|
10
|
+
expr.map { |e| convert_to_elastic(e) }
|
11
|
+
else
|
12
|
+
expr.respond_to?(:as_elastic) ? expr.as_elastic : expr
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def ==(other)
|
data/lib/arelastic/queries.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Arelastic
|
2
|
+
module Queries
|
3
|
+
class Bool < Arelastic::Queries::Query
|
4
|
+
attr_accessor :options
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def as_elastic
|
10
|
+
params = {}
|
11
|
+
options.each do |key, value|
|
12
|
+
params[key] = convert_to_elastic(value)
|
13
|
+
end
|
14
|
+
|
15
|
+
{ "bool" => params }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -13,7 +13,7 @@ class Arelastic::Filters::NestedTest < MiniTest::Unit::TestCase
|
|
13
13
|
}
|
14
14
|
}
|
15
15
|
|
16
|
-
assert_equal expected, Arelastic::Filters::Nested.new('bunnies', Arelastic::Searches::Query(Arelastic::Queries::Match.new('name', 'Harry'))).as_elastic
|
16
|
+
assert_equal expected, Arelastic::Filters::Nested.new('bunnies', Arelastic::Searches::Query.new(Arelastic::Queries::Match.new('name', 'Harry'))).as_elastic
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class Arelastic::Queries::BoolTest < MiniTest::Unit::TestCase
|
4
|
+
def test_as_elastic
|
5
|
+
bool = Arelastic::Queries::Bool.new(
|
6
|
+
'must' => {
|
7
|
+
'prefix' => {
|
8
|
+
'user' => 'kimchy'
|
9
|
+
}
|
10
|
+
},
|
11
|
+
'must_not' => Arelastic::Queries::Match.new('color', 'green'),
|
12
|
+
'should' => [
|
13
|
+
Arelastic::Queries::Match.new('height', 6)
|
14
|
+
]
|
15
|
+
)
|
16
|
+
|
17
|
+
expected = {
|
18
|
+
'bool' => {
|
19
|
+
'must' => {
|
20
|
+
'prefix' => {
|
21
|
+
'user' => 'kimchy'
|
22
|
+
}
|
23
|
+
},
|
24
|
+
'must_not' => {
|
25
|
+
'match' => {
|
26
|
+
'color'=>'green'
|
27
|
+
}
|
28
|
+
},
|
29
|
+
'should' => [
|
30
|
+
'match' => {
|
31
|
+
'height' => 6
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
assert_equal expected, bool.as_elastic
|
38
|
+
end
|
39
|
+
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: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Higgins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build Elastic Search queries with objects
|
14
14
|
email: developer@matthewhiggins.com
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/arelastic/nodes/hash_group.rb
|
64
64
|
- lib/arelastic/nodes/node.rb
|
65
65
|
- lib/arelastic/nodes.rb
|
66
|
+
- lib/arelastic/queries/bool.rb
|
66
67
|
- lib/arelastic/queries/constant_score.rb
|
67
68
|
- lib/arelastic/queries/field.rb
|
68
69
|
- lib/arelastic/queries/filtered.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- test/arelastic/mappings/types/multi_field_test.rb
|
113
114
|
- test/arelastic/mappings/types/string_test.rb
|
114
115
|
- test/arelastic/nodes/node_test.rb
|
116
|
+
- test/arelastic/queries/bool_test.rb
|
115
117
|
- test/arelastic/queries/filtered_test.rb
|
116
118
|
- test/arelastic/queries/match_all_test.rb
|
117
119
|
- test/arelastic/queries/multi_match_test.rb
|