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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba55aa7317d9ac4acbace9b59e95969d5759a2bf
|
4
|
+
data.tar.gz: 9a930c1afe32ed4195e3184854b74d07937e38f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d058e47f7764a219af8abafcd0efce38f0beebd18730cb99d3223b0c4a1b0801dfa1531946c505e147882004a54d3b4014b0158eb1beeeca62bc0e307ec7d74
|
7
|
+
data.tar.gz: 87fc7daa4404ed7fc49518e4ea0516e7b0911a49756b523b4f4342e63bb4898e6a6cfd42f14c8ade579e1385608d9864188c467993b3ac79a4852231da3bd174
|
data/elastic_record.gemspec
CHANGED
@@ -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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|