elastic_search_framework 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/elastic_search_framework/query.rb +3 -12
- data/lib/elastic_search_framework/version.rb +1 -1
- data/spec/query_spec.rb +12 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a2a5f0c0573e1ce1ea95fe0206a05a2228bf2fb9e1a99f04e61f6fd64ced47
|
4
|
+
data.tar.gz: 1ccf3eec2961929a4c042585131f2dffa16ddddac011536ee71b1d08582b33a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63890595521aa8816cef97190b39491d8f7f62d890e293f5311b354c9101f016dc9da630208cb6b8e0d90cf9e026b86a5e5f6390c787b02dc6c7ba03183be064
|
7
|
+
data.tar.gz: a5429fd019a6cf5b6ad3606c44dc42380f49c4f07f6dec35b5abbeb2676e1095a15b681e2f92915dbd01c386acb24e9217a63a64a700657c2d0d8348232e4f8e
|
@@ -23,7 +23,7 @@ module ElasticSearchFramework
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def contains?(value)
|
26
|
-
condition(expression: ':', value: value)
|
26
|
+
condition(expression: ':', value: "*#{value}*")
|
27
27
|
self
|
28
28
|
end
|
29
29
|
|
@@ -91,11 +91,11 @@ module ElasticSearchFramework
|
|
91
91
|
when :field
|
92
92
|
@expression_string += ' ' + p[:value].to_s
|
93
93
|
when :condition
|
94
|
-
@expression_string += p[:expression].to_s +
|
94
|
+
@expression_string += p[:expression].to_s + p[:value].to_s
|
95
95
|
when :exists
|
96
96
|
@expression_string += ' _exists_:' + p[:field].to_s
|
97
97
|
when :not_eq
|
98
|
-
@expression_string += ' NOT (' + p[:field].to_s + ':' +
|
98
|
+
@expression_string += ' NOT (' + p[:field].to_s + ':' + p[:value].to_s + ')'
|
99
99
|
when :and
|
100
100
|
@expression_string += ' AND'
|
101
101
|
when :or
|
@@ -111,14 +111,5 @@ module ElasticSearchFramework
|
|
111
111
|
def condition(expression:, value:)
|
112
112
|
@parts << { type: :condition, expression: expression, value: value }
|
113
113
|
end
|
114
|
-
|
115
|
-
def format_value(value)
|
116
|
-
result = value.to_s
|
117
|
-
if value.is_a?(String)
|
118
|
-
result = '"' + value + '"'
|
119
|
-
end
|
120
|
-
result
|
121
|
-
end
|
122
|
-
|
123
114
|
end
|
124
115
|
end
|
data/spec/query_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe ElasticSearchFramework::Query do
|
2
4
|
|
3
5
|
subject do
|
@@ -7,7 +9,7 @@ RSpec.describe ElasticSearchFramework::Query do
|
|
7
9
|
describe '#build' do
|
8
10
|
it 'should build the expected query string' do
|
9
11
|
subject.name.eq('fred').and.age.gt(18).and.gender.not_eq('male')
|
10
|
-
expect(subject.build).to eq 'name:
|
12
|
+
expect(subject.build).to eq 'name:fred AND age:>18 AND NOT (gender:male)'
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -70,13 +72,21 @@ RSpec.describe ElasticSearchFramework::Query do
|
|
70
72
|
results = ExampleIndex.query.number.gt_eq(15).execute
|
71
73
|
expect(results.length).to eq 2
|
72
74
|
|
75
|
+
results = ExampleIndex.query.number.lt(15).execute
|
76
|
+
expect(results.length).to eq 2
|
77
|
+
|
78
|
+
results = ExampleIndex.query.number.lt_eq(15).execute
|
79
|
+
expect(results.length).to eq 3
|
80
|
+
|
73
81
|
results = ExampleIndex.query.name.not_eq('john').execute
|
74
82
|
expect(results.length).to eq 3
|
83
|
+
|
84
|
+
results = ExampleIndex.query.name.contains?('oh').execute
|
85
|
+
expect(results.length).to eq 1
|
75
86
|
end
|
76
87
|
|
77
88
|
after do
|
78
89
|
ExampleIndex.delete
|
79
90
|
end
|
80
91
|
end
|
81
|
-
|
82
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_search_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|