Commit 4f1c9882c87da8e63f9083d2c470bec4ff5f3b2f
1 parent
295f43ba
Exists in
master
and in
17 other branches
Version bump to 4.0.2 [skip ci]
Showing
3 changed files
with
10 additions
and
10 deletions
Show diff stats
CHANGELOG.md
README.md
@@ -1483,22 +1483,22 @@ indices_boost: {Category => 2, Product => 1} | @@ -1483,22 +1483,22 @@ indices_boost: {Category => 2, Product => 1} | ||
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. | 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 | 1484 | ||
1485 | ```ruby | 1485 | ```ruby |
1486 | -products = Product.search "*", scroll: "1m" | ||
1487 | -while products.any? | 1486 | +Product.search("*", scroll: "1m").scroll do |batch| |
1488 | # process batch ... | 1487 | # process batch ... |
1489 | - | ||
1490 | - products = products.scroll | ||
1491 | end | 1488 | end |
1492 | ``` | 1489 | ``` |
1493 | 1490 | ||
1494 | -You should call `scroll` on each new set of results, not the original result. | ||
1495 | - | ||
1496 | -On the master branch, you can also do: | 1491 | +You can also scroll batches manually. |
1497 | 1492 | ||
1498 | ```ruby | 1493 | ```ruby |
1499 | -Product.search("*", scroll: "1m").scroll do |batch| | 1494 | +products = Product.search "*", scroll: "1m" |
1495 | +while products.any? | ||
1500 | # process batch ... | 1496 | # process batch ... |
1497 | + | ||
1498 | + products = products.scroll | ||
1501 | end | 1499 | end |
1500 | + | ||
1501 | +products.clear_scroll | ||
1502 | ``` | 1502 | ``` |
1503 | 1503 | ||
1504 | ## Nested Data | 1504 | ## Nested Data |
lib/searchkick/version.rb