Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
a51f162
Update rubocop requirement from 1.63.4 to 1.63.5 (#949)
dependabot[bot] May 23, 2024
86f9e3c
Update rubocop requirement from 1.63.5 to 1.64.1 (#953)
dependabot[bot] Jun 6, 2024
2d6a3f5
Rename team (#957)
dgsuarez Jul 10, 2024
7b4ae30
Update rubocop requirement from 1.64.1 to 1.65.0 (#958)
dependabot[bot] Jul 18, 2024
0c50cb8
Update rubocop requirement from 1.65.0 to 1.65.1 (#961)
dependabot[bot] Aug 7, 2024
84c0eed
ElasticSearch v. 8 upgrade (#962)
ql Aug 30, 2024
d2c38f7
Bump chewy version to 8.0.0-beta (#963)
Sep 4, 2024
5193d28
Assign dependabot PR's to sre (#966)
ebeagusamuel Sep 13, 2024
17597e6
Adding Ruby 3.3 and Rails 7.2 to CI matrix (#967)
jotolo Sep 30, 2024
21c5407
updating ruby and active record versions based on test suite (#968)
jotolo Oct 7, 2024
6a2176f
Fix id conversion issue in delayed_sidekiq strategy (#964)
sundus-y Oct 8, 2024
7b09b20
Add Ruby 3.4 to CI matrix
tylerwillingham Oct 14, 2025
8d8c778
Add Rails 8.0 to CI matrix
tylerwillingham Oct 14, 2025
6b202d5
Remove EOL Ruby versions 3.0 and 3.1 from CI matrix
tylerwillingham Oct 14, 2025
18132fe
Update codeowners
bbatsov Nov 21, 2025
c4624f0
[Fix #980] Remove mention of journal_name from the docs
bbatsov Nov 21, 2025
767c850
Tweak some wording
bbatsov Nov 21, 2025
e55bfc1
Bump the copyright years
bbatsov Nov 21, 2025
fde2fdc
Bump the copyright years
bbatsov Nov 21, 2025
be79f8f
Drop support for Rails <= 7.1
bbatsov Feb 25, 2026
23b5721
Update RuboCop to 1.84.2 and regenerate todo
bbatsov Feb 25, 2026
eb591ec
Update sqlite3 to ~> 2.1 and pin unparser to ~> 0.6.15
bbatsov Feb 25, 2026
b25cfc0
Modernize GitHub Actions and docker-compose setup
bbatsov Feb 25, 2026
cd5fd71
Fix FrozenError in Syncer when mutating frozen arrays
bbatsov Feb 25, 2026
ca10cc7
Fix specs broken by Ruby 3.4 Hash#inspect format change
bbatsov Feb 25, 2026
010e129
Update README compatibility to reflect current Ruby/Rails support
bbatsov Feb 25, 2026
f7b606d
Add note about Ruby/Rails version support policy
bbatsov Feb 25, 2026
845f34c
Fix typos and grammar in documentation
bbatsov Feb 25, 2026
2d07d48
Split README into focused documentation files
bbatsov Feb 25, 2026
f74a271
Improve documentation: cross-links, troubleshooting, docs index
bbatsov Feb 25, 2026
8b4bd31
Modernize test suite: replace deprecated syntax, remove dead tests
bbatsov Feb 25, 2026
4c8d17f
Release Chewy 8.0.0
bbatsov Feb 25, 2026
2d0b089
Update gemspec files
ericproulx Jan 11, 2025
a7719e0
Add CHANGELOG.md entry
ericproulx Jan 12, 2025
259089f
Capture output in rake helper spec
mjankowski Feb 25, 2026
7049f57
Drop rspec-its dependency
bbatsov Feb 25, 2026
423a8d0
Add non-Rails usage guide and FAQ section
bbatsov Feb 26, 2026
ced6168
Add getting-started tutorial
bbatsov Feb 26, 2026
2c99c51
Improve querying, indexing and testing docs
bbatsov Feb 26, 2026
40f3a58
Add rails 8.1 to CI matrix
mjankowski Feb 26, 2026
884b1f3
Replace parser gem with prism for Witchcraft AST parsing on Ruby 3.3+…
t6n Mar 4, 2026
677b694
Add missing specs for untested source files
bbatsov Feb 26, 2026
f6e3bff
Allow ruby version 4.0 (#1003)
mjankowski Mar 12, 2026
8aef6af
Release Chewy 8.0.1 (#1005)
AlfonsoUceda Mar 12, 2026
6f4beeb
Remove dead Code Climate and Inch CI badges
bbatsov Mar 15, 2026
d4ee71f
Improve contributing documentation (#1014)
mattmenefee Mar 25, 2026
619f895
Switch rubocop CI output to GitHub annotations format (#1012)
mattmenefee Mar 25, 2026
7206c18
Replace deprecated Sidekiq testing API with new Sidekiq 8.1+ API (#1011)
mattmenefee Mar 25, 2026
f5793b4
Silence AR Migration output during spec runs (#1006)
mjankowski Mar 25, 2026
ac0cba3
Fix the drop_indices helper for ES version portability (#1013)
mattmenefee Mar 25, 2026
ba6a0d0
Activate and fix rubocop-rake plugin cops (#1015)
mjankowski Mar 25, 2026
4ed5132
Add Chewy 7/ES 7 to Chewy 8/ES 8 migration guide (#1010)
mattmenefee Mar 25, 2026
764528b
Promote Elasticsearch to a native GitHub Actions service (#1008)
mattmenefee Mar 25, 2026
0ce311b
Update rubocop to version 1.86.0 (#1016)
mjankowski Mar 25, 2026
70de104
Raise error in #scroll_batches when search backend returns a failure …
tomdev Mar 26, 2026
ebf0cf9
[PF] Rubocop offenses are corrected, CHANGELOG entries are added (#1017)
AlfonsoUceda Mar 26, 2026
dd57163
Add runtime_mappings support (#887)
TakuyaKurimoto Mar 27, 2026
149a28b
Chewy::Stash::Journal.for uses a single terms filter (#1018)
AlfonsoUceda May 28, 2026
c793fb0
Add context: option to import for passing custom data to crutches and…
dimitrikochnev May 28, 2026
3835ffe
Context parallel fix (#1020)
AlfonsoUceda May 28, 2026
6f49e72
v8.1.0 is released (#1019)
AlfonsoUceda May 28, 2026
b196a10
reset! alias swap is atomic (#1021)
AlfonsoUceda May 29, 2026
8b78426
Import progressbar feature is reintroduced (#1022)
AlfonsoUceda May 29, 2026
6ab53cc
Replace deprecated ZRANGEBYSCORE in delayed_sidekiq worker (#1024)
AlfonsoUceda May 29, 2026
129e2c8
update_fields: [] is treated as a no-op (#1023)
AlfonsoUceda May 29, 2026
11728e5
v8.2.0 is released (#1025)
AlfonsoUceda May 29, 2026
1e92209
import_count on multi-select relations is corrected (#1026)
AlfonsoUceda May 29, 2026
599305f
v8.2.1 is released (#1027)
AlfonsoUceda Jun 1, 2026
ca71816
Remove obsolete _type field references (#1028)
mattmenefee Jun 2, 2026
e4ef3f6
Fix misspelled extract_lambdas in Witchcraft (#1030)
mattmenefee Jun 2, 2026
a31b9cf
Compiled compose path replaces witchcraft! as the default (#1032)
AlfonsoUceda Jun 3, 2026
3376c21
v8.3.0 is released (#1033)
AlfonsoUceda Jun 3, 2026
83e71a6
Gemfiles are simplified (#1035)
AlfonsoUceda Jun 4, 2026
7bd98a6
Scroll context for an empty result is cleared (#1037)
AlfonsoUceda Jun 5, 2026
ca4f6f5
v8.3.1 is released (#1038)
AlfonsoUceda Jun 5, 2026
e3f46f0
Chewy.close_client closes Elasticsearch connections (#1036)
AlfonsoUceda Jun 8, 2026
d113e7e
delayed_sidekiq Array type error on Sidekiq 7+ is corrected (#1034)
AlfonsoUceda Jun 8, 2026
ef4ec3d
[OPS-3702] Add bundler cooldown of 7 days (#1039)
AlfonsoUceda Jun 15, 2026
9029b5b
v8.4.0 is released (#1040)
AlfonsoUceda Jun 17, 2026
99b1982
[Fix #1042] Symbol#to_proc field values on the compiled compose path …
AlfonsoUceda Jun 19, 2026
5885239
Bump actions/checkout from 6 to 7 (#1044)
dependabot[bot] Jun 24, 2026
2dbc54e
Update dependabot (#1046)
AlfonsoUceda Jul 13, 2026
21594c8
Bump ruby/setup-ruby from 1 to 1.316.0 (#1047)
dependabot[bot] Jul 15, 2026
67fbbd5
Dev/test dependency cleanup (#1048)
AlfonsoUceda Jul 15, 2026
ff766e4
Bump ruby/setup-ruby from 1.316.0 to 1.319.0 (#1049)
dependabot[bot] Jul 22, 2026
7616b35
Pin GitHub Actions to commit SHAs (#1050)
Totara-thib Jul 23, 2026
65c8a25
Add Plumber to watch workflow security (#1051)
Totara-thib Aug 3, 2026
75c170c
Bump ruby/setup-ruby from 1.319.0 to 1.321.0 (#1052)
dependabot[bot] Aug 3, 2026
73897f5
Update Plumber to v0.4.28 and drop the local config (#1053)
Totara-thib Aug 4, 2026
95cd54a
Bump getplumber/plumber from 0.4.28 to 0.4.30 (#1054)
dependabot[bot] Aug 12, 2026
f9d22ef
Bump getplumber/plumber from 0.4.30 to 0.4.36 (#1055)
dependabot[bot] Aug 19, 2026
4e7d702
Bump getplumber/plumber from 0.4.36 to 0.4.39 (#1056)
dependabot[bot] Aug 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.github/workflows @toptal/platform-sre
* @toptal/sre
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ updates:
- "ruby"
- "dependencies"
reviewers:
- "toptal/devx"
- "toptal/sre"
registries:
- toptal-github
insecure-external-code-execution: allow
Expand All @@ -38,5 +38,5 @@ updates:
- "dependencies"
- "gha"
reviewers:
- "toptal/devx"
- "toptal/sre"
open-pull-requests-limit: 3
14 changes: 7 additions & 7 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '3.0', '3.1', '3.2' ]
gemfile: [rails.6.1.activerecord, rails.7.0.activerecord, rails.7.1.activerecord]
ruby: [ '3.2', '3.3', '3.4' ]
gemfile: [rails.6.1.activerecord, rails.7.0.activerecord, rails.7.1.activerecord, rails.7.2.activerecord, rails.8.0.activerecord]
name: ${{ matrix.ruby }}-${{ matrix.gemfile }}

env:
Expand All @@ -41,11 +41,11 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@9de0f78f306e4ebc0838f057e6b754364685e759
with:
stack-version: 7.10.1
port: 9250
- name: Start containers
run: |
docker compose up elasticsearch_test -d
sleep 15

- name: Tests
run: bundle exec rspec

Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

### Bugs Fixed

* [#964](https://github.com/toptal/chewy/pull/964): Fix `delayed_sidekiq` worker to handle UUID primary keys correctly.

## 8.0.0-beta (2024-08-27)

### New Features

* [#962](https://github.com/toptal/chewy/pull/962): ElasticSearch v.8 support added

* `delete_all_enabled` setting introduced to align Chewy.massacre with wildcard indices deletion disabled in ES 8 by default

### Changes

### Bugs Fixed

## 7.6.0 (2024-05-03)

### Changes
Expand Down
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ Or install it yourself as:

### Ruby

Chewy is compatible with MRI 3.0-3.2¹.
Chewy is compatible with MRI 3.0-3.3¹.

> ¹ Ruby 3 is only supported with Rails 6.1
> ¹ Ruby 3 is supported with Rails 6.1, 7.0, 7.1 and 7.2

### Elasticsearch compatibility matrix

| Chewy version | Elasticsearch version |
| ------------- | ---------------------------------- |
| 8.0.0 | 8.x |
| 7.2.x | 7.x |
| 7.1.x | 7.x |
| 7.0.x | 6.8, 7.x |
Expand All @@ -66,7 +67,7 @@ various Chewy versions.

### Active Record

5.2, 6.0, 6.1 Active Record versions are supported by all Chewy versions.
6.1, 7.0, 7.1, 7.2 Active Record versions are supported by Chewy.

## Getting Started

Expand Down Expand Up @@ -97,7 +98,36 @@ development:
Make sure you have Elasticsearch up and running. You can [install](https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html) it locally, but the easiest way is to use [Docker](https://www.docker.com/get-started):

```shell
$ docker run --rm --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.11.1
$ docker run --rm --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" elasticsearch:8.15.0
```

### Security

Please note that starting from version 8 ElasticSearch has security features enabled by default.
Docker command above has it disabled for local testing convenience. If you want to enable it, omit
`"xpack.security.enabled=false"` part from Docker command, and run these command after starting container (container name `es8` assumed):

Reset password for `elastic` user:
```
docker container exec es8 '/usr/share/elasticsearch/bin/elasticsearch-reset-password' -u elastic
```

Extract CA certificate generated by ElasticSearch on first run:
```
docker container cp es8:/usr/share/elasticsearch/config/certs/http_ca.crt tmp/
```

And then add them to settings:

```yaml
# config/chewy.yml
development:
host: 'localhost:9200'
user: 'elastic'
password: 'SomeLongPassword'
transport_options:
ssl:
ca_file: './tmp/http_ca.crt'
```

### Index
Expand Down Expand Up @@ -941,6 +971,8 @@ Controller actions are wrapped with the configurable value of `Chewy.request_str

It is also a good idea to set up the `:bypass` strategy inside your test suite and import objects manually only when needed, and use `Chewy.massacre` when needed to flush test ES indices before every example. This will allow you to minimize unnecessary ES requests and reduce overhead.

Deprecation note: since version 8 wildcard removing of indices is disabled by default. You can enable it for a cluster with setting `action.destructive_requires_name` to false.

```ruby
RSpec.configure do |config|
config.before(:suite) do
Expand Down
5 changes: 3 additions & 2 deletions chewy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ Gem::Specification.new do |spec|
spec.description = 'Chewy provides functionality for Elasticsearch index handling, documents import mappings and chainable query DSL'
spec.homepage = 'https://github.com/toptal/chewy'
spec.license = 'MIT'
spec.required_ruby_version = '~> 3.0'

spec.files = `git ls-files`.split($RS)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'activesupport', '>= 5.2' # Remove with major version bump, 8.x
spec.add_dependency 'elasticsearch', '>= 7.14.0', '< 8'
spec.add_dependency 'activesupport', '>= 6.1'
spec.add_dependency 'elasticsearch', '>= 8.14', '< 9.0'
spec.add_dependency 'elasticsearch-dsl'
spec.metadata['rubygems_mfa_required'] = 'true'
end
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.4"
services:
elasticsearch_test:
image: "elasticsearch:8.15.0"
environment:
- bootstrap.memory_lock=${ES_MEMORY_LOCK:-false}
- "ES_JAVA_OPTS=-Xms${TEST_ES_HEAP_SIZE:-500m} -Xmx${TEST_ES_HEAP_SIZE:-500m}"
- discovery.type=single-node
- xpack.security.enabled=false
ports:
- "127.0.0.1:9250:9200"
ulimits:
nofile:
soft: 65536
hard: 65536
2 changes: 1 addition & 1 deletion gemfiles/base.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem 'redis', require: false
gem 'rspec', '>= 3.7.0'
gem 'rspec-collection_matchers'
gem 'rspec-its'
gem 'rubocop', '1.63.4'
gem 'rubocop', '1.65.1'
gem 'sqlite3', '~> 1.4'
gem 'timecop'
gem 'unparser'
14 changes: 14 additions & 0 deletions gemfiles/rails.7.2.activerecord.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source 'https://rubygems.org'

gem 'activejob', '~> 7.2.0'
gem 'activerecord', '~> 7.2.0'
gem 'activesupport', '~> 7.2.0'
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'sidekiq', require: false

gem 'rexml'

gemspec path: '../'
eval_gemfile 'base.gemfile'
14 changes: 14 additions & 0 deletions gemfiles/rails.8.0.activerecord.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source 'https://rubygems.org'

gem 'activejob', '~> 8.0.0'
gem 'activerecord', '~> 8.0.0'
gem 'activesupport', '~> 8.0.0'
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'sidekiq', require: false

gem 'rexml'

gemspec path: '../'
eval_gemfile 'base.gemfile'
4 changes: 4 additions & 0 deletions lib/chewy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def wait_for_status
# Be careful, if current prefix is blank, this will destroy all the indexes.
#
def massacre
unless Chewy.settings[:delete_all_enabled]
raise FeatureDisabled, 'Feature disabled by default in ES 8. You can enable it in the cluster and set `delete_all_enabled` option in settings'
end

Chewy.client.indices.delete(index: [Chewy.configuration[:prefix], '*'].reject(&:blank?).join('_'))
Chewy.wait_for_status
end
Expand Down
4 changes: 2 additions & 2 deletions lib/chewy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def initialize
end

def transport_logger=(logger)
Chewy.client.transport.transport.logger = logger
Chewy.client.transport.logger = logger
@transport_logger = logger
end

def transport_tracer=(tracer)
Chewy.client.transport.transport.tracer = tracer
Chewy.client.transport.tracer = tracer
@transport_tracer = tracer
end

Expand Down
3 changes: 3 additions & 0 deletions lib/chewy/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ def initialize(join_field_type, join_field_name, relations)

class ImportScopeCleanupError < Error
end

class FeatureDisabled < Error
end
end
2 changes: 1 addition & 1 deletion lib/chewy/fields/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Root < Chewy::Fields::Base
attr_reader :dynamic_templates, :id

def initialize(name, **options)
super(name, **options)
super

@value ||= -> { self }
@dynamic_templates = []
Expand Down
10 changes: 5 additions & 5 deletions lib/chewy/index/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def exists?
#
def create(*args, **kwargs)
create!(*args, **kwargs)
rescue Elasticsearch::Transport::Transport::Errors::BadRequest
rescue Elastic::Transport::Transport::Errors::BadRequest
false
end

Expand Down Expand Up @@ -83,9 +83,9 @@ def delete(suffix = nil)
result = client.indices.delete index: index_names.join(',')
Chewy.wait_for_status if result
result
# es-ruby >= 1.0.10 handles Elasticsearch::Transport::Transport::Errors::NotFound
# es-ruby >= 1.0.10 handles Elastic::Transport::Transport::Errors::NotFound
# by itself, rescue is for previous versions
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
false
end

Expand All @@ -99,9 +99,9 @@ def delete(suffix = nil)
# UsersIndex.delete '01-2014' # deletes `users_01-2014` index
#
def delete!(suffix = nil)
# es-ruby >= 1.0.10 handles Elasticsearch::Transport::Transport::Errors::NotFound
# es-ruby >= 1.0.10 handles Elastic::Transport::Transport::Errors::NotFound
# by itself, so it is raised here
delete(suffix) or raise Elasticsearch::Transport::Transport::Errors::NotFound
delete(suffix) or raise Elastic::Transport::Transport::Errors::NotFound
end

# Deletes and recreates index. Supports suffixes.
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/index/aliases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def aliases

def empty_if_not_found
yield
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
[]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/index/syncer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def outdated_sync_field_type
@outdated_sync_field_type = mappings
.fetch('properties', {})
.fetch(@index.outdated_sync_field.to_s, {})['type']
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/minitest/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def index_everything!
teardown do
# always destroy indexes between tests
# Prevent croll pollution of test cases due to indexing
Chewy.massacre
drop_indices
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/chewy/search/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Request

delegate :hits, :wrappers, :objects, :records, :documents,
:object_hash, :record_hash, :document_hash,
:total, :max_score, :took, :timed_out?, to: :response
:total, :max_score, :took, :timed_out?, :terminated_early?, to: :response
delegate :each, :size, :to_a, :[], to: :wrappers
alias_method :to_ary, :to_a
alias_method :total_count, :total
Expand Down Expand Up @@ -854,7 +854,7 @@ def count
else
Chewy.client.count(only(WHERE_STORAGES).render)['count']
end
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
0
end

Expand Down Expand Up @@ -891,7 +891,7 @@ def exists?
def first(limit = UNDEFINED)
request_limit = limit == UNDEFINED ? 1 : limit

if performed? && (request_limit <= size || size == total)
if performed? && (terminated_early? || request_limit <= size || size == total)
limit == UNDEFINED ? wrappers.first : wrappers.first(limit)
else
result = except(EXTRA_STORAGES).limit(request_limit).to_a
Expand Down Expand Up @@ -1035,7 +1035,7 @@ def perform(additional = {})
request_body = render.merge(additional)
ActiveSupport::Notifications.instrument 'search_query.chewy', notification_payload(request: request_body) do
Chewy.client.search(request_body)
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
{}
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/chewy/search/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def timed_out?
@timed_out ||= @body['timed_out']
end

# Has the request been terminated early?
#
# @return [true, false]
def terminated_early?
@terminated_early ||= @body['terminated_early']
end

# The `suggest` response part. Returns empty hash if suggests
# were not requested.
#
Expand Down
3 changes: 2 additions & 1 deletion lib/chewy/search/scrolling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def scroll_batches(batch_size: Request::DEFAULT_BATCH_SIZE, scroll: Request::DEF
hits = hits.first(last_batch_size) if last_batch_size != 0 && fetched >= total
yield(hits) if hits.present?
scroll_id = result['_scroll_id']
break if fetched >= total

break if result['terminated_early'] || fetched >= total

result = perform_scroll(scroll: scroll, scroll_id: scroll_id)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/strategy/delayed_sidekiq/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def extract_ids_and_fields(members)

fields = nil if fields.include?(Scheduler::FALLBACK_FIELDS)

[ids.map(&:to_i), fields]
[ids, fields]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Chewy
VERSION = '7.6.0'.freeze
VERSION = '8.0.0-beta'.freeze
end
Loading