elastic_record 1.2.3 → 1.2.4

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: 01876488cf87aafffd46c830a6712dd84f56c83d
4
- data.tar.gz: 7db2399fa5d44bf81a3c157cd23c95d60b040c19
3
+ metadata.gz: ba55aa7317d9ac4acbace9b59e95969d5759a2bf
4
+ data.tar.gz: 9a930c1afe32ed4195e3184854b74d07937e38f7
5
5
  SHA512:
6
- metadata.gz: 4f8a6c431823345a68a2da9d2d6c6099f5449a240068c60aa1f3f6ccbd8d2d74bb95ef3ed2f4c6c4882c0a65c537b298adc0b42b7ecc979b04b82e6cf708181e
7
- data.tar.gz: 032af52b81c1e79b7957934aa1812f809ef8109f18c418d95fd42dcfa70e99472dd28825b62020714d00aad35cc5f5945f95c7923e300d5e982db8c68c7298cc
6
+ metadata.gz: 5d058e47f7764a219af8abafcd0efce38f0beebd18730cb99d3223b0c4a1b0801dfa1531946c505e147882004a54d3b4014b0158eb1beeeca62bc0e307ec7d74
7
+ data.tar.gz: 87fc7daa4404ed7fc49518e4ea0516e7b0911a49756b523b4f4342e63bb4898e6a6cfd42f14c8ade579e1385608d9864188c467993b3ac79a4852231da3bd174
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '1.2.3'
5
+ s.version = '1.2.4'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -2,6 +2,7 @@ module ElasticRecord
2
2
  class Relation
3
3
  class ScanSearch
4
4
  attr_reader :scroll_id
5
+ attr_accessor :total_hits
5
6
 
6
7
  def initialize(model, scroll_id, options = {})
7
8
  @model = model
@@ -57,7 +58,9 @@ module ElasticRecord
57
58
  search_options = {search_type: 'scan', size: options[:batch_size], scroll: options[:keep_alive]}
58
59
  json = klass.elastic_index.search(as_elastic, search_options)
59
60
 
60
- ElasticRecord::Relation::ScanSearch.new(klass, json['_scroll_id'], options)
61
+ ElasticRecord::Relation::ScanSearch.new(klass, json['_scroll_id'], options).tap do |scan_search|
62
+ scan_search.total_hits = json['hits']['total']
63
+ end
61
64
  end
62
65
  end
63
66
  end
@@ -53,17 +53,22 @@ class ElasticRecord::Relation::BatchesTest < MiniTest::Unit::TestCase
53
53
  def test_find_offset_shards
54
54
  create_additional_widgets
55
55
 
56
- #assert_queries 3 do
57
- results = []
58
- Widget.elastic_relation.find_ids_in_batches(batch_size: 1) do |ids|
59
- results << ids
60
- end
61
- #end
56
+ results = []
57
+ Widget.elastic_relation.find_ids_in_batches(batch_size: 1) do |ids|
58
+ results << ids
59
+ end
62
60
 
63
61
  assert_equal 8, results.size
64
62
  results.each do |r| assert_equal 1, r.size end
65
63
  assert_equal ['5', '10', '15', '20', '25', '30', '35', '40'].to_set, results.flatten.to_set
64
+ end
65
+
66
+ def test_create_scan_search
67
+ scan_search = Widget.elastic_relation.create_scan_search
66
68
 
69
+ assert_equal 3, scan_search.total_hits
70
+ refute_nil scan_search.scroll_id
71
+ assert_equal 3, scan_search.request_more_ids.size
67
72
  end
68
73
 
69
74
  private
@@ -84,4 +89,4 @@ class ElasticRecord::Relation::BatchesTest < MiniTest::Unit::TestCase
84
89
  Widget.new(id: 40, color: 'black'),
85
90
  ]
86
91
  end
87
- end
92
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infogroup