elastic_search_framework 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e38cb0d02951b7d4b3d76e1eefdd6f6f1aece78b8155d745c8faff954e0708f
4
- data.tar.gz: ffb17d5fdd74a9cb9098ecebba7073b993b405573ae61ac661cbb2c2b2006075
3
+ metadata.gz: 39a2a5f0c0573e1ce1ea95fe0206a05a2228bf2fb9e1a99f04e61f6fd64ced47
4
+ data.tar.gz: 1ccf3eec2961929a4c042585131f2dffa16ddddac011536ee71b1d08582b33a3
5
5
  SHA512:
6
- metadata.gz: 0f73d01a913e2e858466675bf774e36d41dc87c4060e2bc97f34b0efeadb0fe06d8f43ab0c87a20dccd48248f524d9dc5f6a4e693ed45af83e3f2882e50014e9
7
- data.tar.gz: 12128e76fa8ffaac2177722fe95250e9a520334460da0a3643839b01908a535c238f1a503cb2ff3408760435bf392668bcb557a08bc2d54d23f5d4976e296a98
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 + format_value(p[:value])
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 + ':' + format_value(p[:value]) + ')'
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
@@ -1,3 +1,3 @@
1
1
  module ElasticSearchFramework
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  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:"fred" AND age:>18 AND NOT (gender:"male")'
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.0.0
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-18 00:00:00.000000000 Z
11
+ date: 2018-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler