Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Changes

* [#1028](https://github.com/toptal/chewy/pull/1028): Remove the obsolete `_type` field from mock response helpers (`Chewy::Minitest::Helpers`, `Chewy::Rspec::Helpers`), `EVERFIELDS`, and `Chewy::Index::Wrapper` accessors. Elasticsearch removed `_type` from search responses in 8.0 (ES 7 already returned only the placeholder `_doc`), so these references no longer matched real responses. Also removes the long-obsolete `_parent` entry from `EVERFIELDS`. ([@mattmenefee][])

## 8.2.1 (2026-06-01)

### New Features
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ end
},
"_data":{
"_index":"users",
"_type":"_doc",
"_id":"1",
"_score":0.9808291,
"_source":{
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/index/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def ==(other)
end
end

%w[_id _type _index].each do |name|
%w[_id _index].each do |name|
define_method name do
_data[name]
end
Expand Down
1 change: 0 additions & 1 deletion lib/chewy/minitest/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def mock_elasticsearch_response_sources(index, hits, &block)
'hits' => hits.each_with_index.map do |hit, i|
{
'_index' => index.index_name,
'_type' => '_doc',
'_id' => hit[:id] || (i + 1).to_s,
'_score' => 3.14,
'_source' => hit
Expand Down
1 change: 0 additions & 1 deletion lib/chewy/rspec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def mock_elasticsearch_response_sources(index, hits)
'hits' => hits.each_with_index.map do |hit, i|
{
'_index' => index.index_name,
'_type' => '_doc',
'_id' => (i + 1).to_s,
'_score' => 3.14,
'_source' => hit
Expand Down
4 changes: 2 additions & 2 deletions lib/chewy/search/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Request
include Scoping
include Scrolling
UNDEFINED = Class.new.freeze
EVERFIELDS = %w[_index _type _id _parent _routing].freeze
EVERFIELDS = %w[_index _id _routing].freeze
DELEGATED_METHODS = %i[
query filter post_filter knn order reorder docvalue_fields
track_scores track_total_hits request_cache explain version profile
Expand Down Expand Up @@ -952,7 +952,7 @@ def find(*ids)

# Returns and array of values for specified fields.
# Uses `source` to restrict the list of returned fields.
# Fields `_id`, `_type`, `_routing` and `_index` are also supported.
# Fields `_id`, `_routing` and `_index` are also supported.
#
# @overload pluck(field)
# If single field is passed - it returns and array of values.
Expand Down
3 changes: 3 additions & 0 deletions migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ In order to upgrade Chewy 7/Elasticsearch 7 to Chewy 8/Elasticsearch 8 in the mo
* In test suites, consider switching to targeted index deletion instead of `Chewy.massacre`
* Configure Elasticsearch 8 security:
* ES 8 enables security features by default. Ensure your Chewy configuration includes proper authentication (username/password or API key) and SSL/TLS settings as needed.
* Update test assertions for mock responses:
* If you use `mock_elasticsearch_response_sources` (in `Chewy::Minitest::Helpers` or `Chewy::Rspec::Helpers`), remove any assertions expecting `'_type' => '_doc'` in the mock hits it returns. The `_type` field has been removed from these helpers to match actual ES response format (ES 8 removed `_type` from search responses; ES 7 still returned the placeholder `'_doc'`).
* If you use `mock_elasticsearch_response` with a hand-crafted raw response hash, ensure your raw response does not include `'_type'` for consistency with ES 8+ responses.
* Run your test suite on Chewy 8 / Elasticsearch 8
* Run manual tests on Chewy 8 / Elasticsearch 8
* Upgrade to Chewy 8
Expand Down
1 change: 0 additions & 1 deletion spec/chewy/minitest/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def assert_equal(expected, actual, message)
[
{
'_index' => 'dummies',
'_type' => '_doc',
'_id' => '2',
'_score' => 3.14,
'_source' => source
Expand Down
1 change: 0 additions & 1 deletion spec/chewy/rspec/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
[
{
'_index' => 'cities',
'_type' => '_doc',
'_id' => '1',
'_score' => 3.14,
'_source' => source
Expand Down
2 changes: 0 additions & 2 deletions spec/chewy/search/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
let(:raw_response) do
{'hits' => {'hits' => [
{'_index' => 'cities',
'_type' => 'city',
'_id' => '1',
'_score' => 1.3,
'_source' => {'id' => 2, 'rating' => 0}}
Expand All @@ -155,7 +154,6 @@
let(:raw_response) do
{'hits' => {'hits' => [
{'_index' => 'countries',
'_type' => 'country',
'_id' => '2',
'_score' => 1.2,
'_explanation' => {foo: 'bar'}}
Expand Down