co-elastic-query 3.0.3 → 3.1.0

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: 6f01c74301eadb7c79db3db995ad7bf4992273e2
4
- data.tar.gz: a070f73ec86e785ee80e6b125bf9ca9e202bc985
3
+ metadata.gz: 9b151553366a3789ac06d80546f5eea887afc35f
4
+ data.tar.gz: 7d45f4eefb2c5052b666d69e5683861b3989df18
5
5
  SHA512:
6
- metadata.gz: 0a4bb9fa597922f7e6981d5c26b5719983f9741a33e04cef497b1f0af61e2c563b630a5f85cebcef44d167b15913ddd498bfdd47968b3438fe94fd4f4979324d
7
- data.tar.gz: 6fa9d4f3046b73b528564d9d848d3a5255d7f7d2e516b75c0af588c2aec342a71c4f9bb83c8cceb86399593e4cdd7cb7425401fed7d7950a0a75e6887e4acf25
6
+ metadata.gz: 6106ba041466def4f08aceffeca77a29294c32d5530e606fd0ac86837ac2397ead9150da20fb8ade3f341d42db31ff78525090e047e1a063a1c48a876cd7dd2b
7
+ data.tar.gz: c8b0e70ad054708d36af51b780096775b421e888a270392d684ce6e85fa803d9c36c341550392cd71d0ae1381533e5846cf94e21bb65f00ab40a6ef76efbc792
@@ -315,9 +315,11 @@ class Elastic
315
315
  SCORE = ['_score'.freeze]
316
316
  INDEX = (ENV['ELASTIC_INDEX'] || 'default').freeze
317
317
 
318
- def initialize(klass, opts = {})
319
- @klass = klass
320
- @filter = klass.design_document
318
+ def initialize(klass = nil, **opts)
319
+ if klass
320
+ @klass = klass
321
+ @filter = klass.design_document
322
+ end
321
323
  @index = opts[:index] || INDEX
322
324
  @use_couch_type = opts[:use_couch_type] || false
323
325
  end
@@ -338,7 +340,11 @@ class Elastic
338
340
  # currently logged in user is an admin of the group). nils are removed
339
341
  # from the list.
340
342
  result = Elastic.search(query)
341
- records = Array(@klass.find_by_id(result[HITS][HITS].map {|entry| entry[ID]}))
343
+ records = if @klass
344
+ Array(@klass.find_by_id(result[HITS][HITS].map {|entry| entry[ID]}))
345
+ else
346
+ Array(result[HITS][HITS].map { |entry| ::CouchbaseOrm.try_load(entry[ID]) }).compact
347
+ end
342
348
  results = block_given? ? (records.map {|record| yield record}).compact : records
343
349
 
344
350
  # Ensure the total is accurate
@@ -377,10 +383,12 @@ class Elastic
377
383
 
378
384
  filters = opt[:filters] || []
379
385
 
380
- if @use_couch_type
381
- filters.unshift({term: {'doc.type' => @filter}})
382
- else
383
- filters.unshift({type: {value: @filter}})
386
+ if @filter
387
+ if @use_couch_type
388
+ filters.unshift({term: {'doc.type' => @filter}})
389
+ else
390
+ filters.unshift({type: {value: @filter}})
391
+ end
384
392
  end
385
393
 
386
394
  {
@@ -1,3 +1,3 @@
1
1
  module CoElasticQuery
2
- VERSION = "3.0.3"
2
+ VERSION = "3.1.0"
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: 3.0.3
4
+ version: 3.1.0
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: 2017-08-16 00:00:00.000000000 Z
12
+ date: 2017-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler