searchkick 4.0.1 → 4.0.2
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -4
- data/lib/searchkick/index_options.rb +1 -2
- data/lib/searchkick/query.rb +1 -0
- data/lib/searchkick/results.rb +33 -11
- data/lib/searchkick/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb0777c063adddb2c339761f92c7ffaf3646daf869b7360dafe662ce0b38056b
|
4
|
+
data.tar.gz: '062070815d5b78a2cb3b7c4f0dc9408730e8facd72ce223d25a6bafe9bd46d12'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3c08562e9a52dc950ff74ebb532beac936367e75c3a2e794079217caed899c566df50265e602c75d13e44eafd03c09821cfb10a88398d0897e5b0a85c76cf7d
|
7
|
+
data.tar.gz: c211a672924cec7627d0bf9b1e700c8ef6d037a745a7867e39b3cf8302f8f84d163d6911a893b0f8adf4073bf3f624cb517224e96522d0b5e209b081300a12f7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,7 @@ Plus:
|
|
37
37
|
- [Performance](#performance)
|
38
38
|
- [Elasticsearch DSL](#advanced)
|
39
39
|
- [Reference](#reference)
|
40
|
+
- [Testing](#testing)
|
40
41
|
|
41
42
|
## Getting Started
|
42
43
|
|
@@ -1479,18 +1480,26 @@ indices_boost: {Category => 2, Product => 1}
|
|
1479
1480
|
|
1480
1481
|
## Scroll API
|
1481
1482
|
|
1482
|
-
|
1483
|
+
Searchkick also supports the [scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html). Scrolling is not intended for real time user requests, but rather for processing large amounts of data.
|
1484
|
+
|
1485
|
+
```ruby
|
1486
|
+
Product.search("*", scroll: "1m").scroll do |batch|
|
1487
|
+
# process batch ...
|
1488
|
+
end
|
1489
|
+
```
|
1490
|
+
|
1491
|
+
You can also scroll batches manually.
|
1483
1492
|
|
1484
1493
|
```ruby
|
1485
1494
|
products = Product.search "*", scroll: "1m"
|
1486
1495
|
while products.any?
|
1487
|
-
#
|
1496
|
+
# process batch ...
|
1488
1497
|
|
1489
1498
|
products = products.scroll
|
1490
1499
|
end
|
1491
|
-
```
|
1492
1500
|
|
1493
|
-
|
1501
|
+
products.clear_scroll
|
1502
|
+
```
|
1494
1503
|
|
1495
1504
|
## Nested Data
|
1496
1505
|
|
@@ -13,7 +13,7 @@ module Searchkick
|
|
13
13
|
index_type = index_type.call if index_type.respond_to?(:call)
|
14
14
|
end
|
15
15
|
|
16
|
-
custom_mapping = options[:
|
16
|
+
custom_mapping = options[:mappings] || {}
|
17
17
|
if below70 && custom_mapping.keys.map(&:to_sym).include?(:properties)
|
18
18
|
# add type
|
19
19
|
custom_mapping = {index_type => custom_mapping}
|
@@ -23,7 +23,6 @@ module Searchkick
|
|
23
23
|
settings = options[:settings] || {}
|
24
24
|
mappings = custom_mapping
|
25
25
|
else
|
26
|
-
|
27
26
|
default_type = "text"
|
28
27
|
default_analyzer = :searchkick_index
|
29
28
|
keyword_mapping = {type: "keyword"}
|
data/lib/searchkick/query.rb
CHANGED
@@ -435,6 +435,7 @@ module Searchkick
|
|
435
435
|
warn "[searchkick] WARNING: Passing child models to models option throws off hits and pagination - use type option instead"
|
436
436
|
|
437
437
|
# uncomment once aliases are supported with _index
|
438
|
+
# see https://github.com/elastic/elasticsearch/issues/23306
|
438
439
|
# index_type_or =
|
439
440
|
# models.map do |m|
|
440
441
|
# v = {_index: m.searchkick_index.name}
|
data/lib/searchkick/results.rb
CHANGED
@@ -228,22 +228,44 @@ module Searchkick
|
|
228
228
|
def scroll
|
229
229
|
raise Searchkick::Error, "Pass `scroll` option to the search method for scrolling" unless scroll_id
|
230
230
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
231
|
+
if block_given?
|
232
|
+
records = self
|
233
|
+
while records.any?
|
234
|
+
yield records
|
235
|
+
records = records.scroll
|
236
|
+
end
|
235
237
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
238
|
+
records.clear_scroll
|
239
|
+
else
|
240
|
+
params = {
|
241
|
+
scroll: options[:scroll],
|
242
|
+
scroll_id: scroll_id
|
243
|
+
}
|
244
|
+
|
245
|
+
begin
|
246
|
+
# TODO Active Support notifications for this scroll call
|
247
|
+
Searchkick::Results.new(@klass, Searchkick.client.scroll(params), @options)
|
248
|
+
rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
|
249
|
+
if e.class.to_s =~ /NotFound/ && e.message =~ /search_context_missing_exception/i
|
250
|
+
raise Searchkick::Error, "Scroll id has expired"
|
251
|
+
else
|
252
|
+
raise e
|
253
|
+
end
|
243
254
|
end
|
244
255
|
end
|
245
256
|
end
|
246
257
|
|
258
|
+
def clear_scroll
|
259
|
+
begin
|
260
|
+
# try to clear scroll
|
261
|
+
# not required as scroll will expire
|
262
|
+
# but there is a cost to open scrolls
|
263
|
+
Searchkick.client.clear_scroll(scroll_id: scroll_id)
|
264
|
+
rescue Elasticsearch::Transport::Transport::Error
|
265
|
+
# do nothing
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
247
269
|
private
|
248
270
|
|
249
271
|
def results_query(records, hits)
|
data/lib/searchkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05
|
11
|
+
date: 2019-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|