co-elastic-query 1.0.5 → 1.0.6

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: d7cf122783303d47b0df499179ae68b7c651c7c7
4
- data.tar.gz: f1e3677f0bdd09fe62c47e85a39e8ad71d65b31c
3
+ metadata.gz: a252f8562630b0a0d3241d4073ee19a8ed90145b
4
+ data.tar.gz: f5392cc5b35e261ecf9a973da1a40efb7623d640
5
5
  SHA512:
6
- metadata.gz: 4dc30af59ddb3292ce6f00124cea1a12e40fed3973acb57e9aca2b0da54a538791d73cb3e5107ba4cca313c331d9ab7fd0cb0b8d5b1c9afcb21551243b85948c
7
- data.tar.gz: 0173e9e5e5735ac2599d902ae0f4c84d342a2f4292bd6667aa631be7ad940f0b2d2cc2545d27a544a030e7c250639617a84f7a3badffbe86c044a85b2441b3bd
6
+ metadata.gz: 0cfbfbecd60ddc4e7f89b269afa0a4d25a5ebe22d188afa1978183786802c52419b10a69aec9ae9f35ed1442f161e819e81f47064d91b6ac001b3ae10836a0f5
7
+ data.tar.gz: abf22384ebb70f7c5b030179b023126e2a10697f8fb063f14da1b06fccd0c1752c752f034f868ab89f148d94dafd877ee50aa9beb2ff1beb46a1242be563fc99
@@ -7,6 +7,7 @@ class Elastic
7
7
 
8
8
  @filters = nil
9
9
  @search = "#{query[:q]}*"
10
+ @fields = ['_all'.freeze]
10
11
 
11
12
  @limit = query[:limit] || 20
12
13
  @limit = @limit.to_i
@@ -18,9 +19,7 @@ class Elastic
18
19
  end
19
20
 
20
21
 
21
- attr_accessor :offset
22
- attr_accessor :limit
23
- attr_accessor :sort
22
+ attr_accessor :offset, :limit, :sort, :fields
24
23
 
25
24
  def raw_filter(filter)
26
25
  @raw_filter ||= []
@@ -28,6 +27,10 @@ class Elastic
28
27
  self
29
28
  end
30
29
 
30
+ def search_field(field)
31
+ @fields.unshift(field)
32
+ end
33
+
31
34
 
32
35
  # filters is in the form {fieldname1: ['var1','var2',...], fieldname2: ['var1','var2'...]}
33
36
  # NOTE:: may overwrite an existing filter in merge
@@ -161,7 +164,8 @@ class Elastic
161
164
  if @hasChild || @hasParent
162
165
  should = [{
163
166
  simple_query_string: {
164
- query: @search
167
+ query: @search,
168
+ fields: @fields
165
169
  }
166
170
  }]
167
171
 
@@ -171,7 +175,8 @@ class Elastic
171
175
  type: @hasChild,
172
176
  query: {
173
177
  simple_query_string: {
174
- query: @search
178
+ query: @search,
179
+ fields: @fields
175
180
  }
176
181
  }
177
182
  }
@@ -184,7 +189,8 @@ class Elastic
184
189
  parent_type: @hasParent,
185
190
  query: {
186
191
  simple_query_string: {
187
- query: @search
192
+ query: @search,
193
+ fields: @fields
188
194
  }
189
195
  }
190
196
  }
@@ -205,7 +211,8 @@ class Elastic
205
211
  query_obj = {
206
212
  query: {
207
213
  simple_query_string: {
208
- query: @search
214
+ query: @search,
215
+ fields: @fields
209
216
  }
210
217
  },
211
218
  filters: fieldfilters,
@@ -1,3 +1,3 @@
1
1
  module CoElasticQuery
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: co-elastic-query
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-11 00:00:00.000000000 Z
12
+ date: 2015-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.4.5
91
+ rubygems_version: 2.4.6
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Elasticsearch query generator