Skip to content

Commit

Permalink
Add ES7 support, prepare 7.0.0 release (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Rabotyaga authored Feb 22, 2021
1 parent 47ad295 commit 3ba07cc
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 26 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
rspec-ruby-26-activerecord52:
docker:
- image: circleci/ruby:2.6
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -120,7 +120,7 @@ jobs:
rspec-ruby-26-activerecord60:
docker:
- image: circleci/ruby:2.6
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -132,7 +132,7 @@ jobs:
rspec-ruby-26-activerecord61:
docker:
- image: circleci/ruby:2.6
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -145,7 +145,7 @@ jobs:
docker:
- image: circleci/ruby:2.6
- image: circleci/mongo:4.2.5
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -157,7 +157,7 @@ jobs:
rspec-ruby-27-activerecord52:
docker:
- image: circleci/ruby:2.7
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -169,7 +169,7 @@ jobs:
rspec-ruby-27-activerecord60:
docker:
- image: circleci/ruby:2.7
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -181,7 +181,7 @@ jobs:
rspec-ruby-27-activerecord61:
docker:
- image: circleci/ruby:2.7
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -194,7 +194,7 @@ jobs:
docker:
- image: circleci/ruby:2.7
- image: circleci/mongo:4.2.5
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand All @@ -206,7 +206,7 @@ jobs:
rspec-ruby-30-activerecord61:
docker:
- image: circleci/ruby:3.0
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
<<: *es-env
working_directory: ~/repo
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@

### New Features

### Changes

### Bugs Fixed

## 7.0.0 (2021-02-22)

### New Features

* [#763](https://github.com/toptal/chewy/pull/763): Added support for Elasticsearch 7 ([@rabotyaga][])

### Changes

* [#757](https://github.com/toptal/chewy/pull/757): **(Breaking)** Fix `Chewy::Index.index` & `Chewy::Index.aliases` to correctly report indexes and aliases ([@mpeychich][], [@dalthon][])
* [#761](https://github.com/toptal/chewy/pull/761): Avoid fetching scope data to check if it is blank ([@dalthon][])

### Bugs Fixed

## 6.0.0 (2021-02-11)

### Changes
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ Chewy is compatible with MRI 2.5-3.0¹.

> ¹ Ruby 3 is only supported with Rails 6.1
### Elasticsearch
### Elasticsearch compatibility matrix

Chewy 5 is compatible with Elasticsearch 5.
| Chewy version | Elasticsearch version |
| ------------- | ---------------------------------- |
| 7.0.0 | 6.8, 7.x |
| 6.0.0 | 5.x, 6.x |
| 5.x | 5.x, limited support for 1.x & 2.x |

Chewy 6 is compatible with Elasticsearch 6. See [Migration guide](migration_guide.md).

Future versions of Chewy will support Elasticsearch 7.
See [Migration guide](migration_guide.md).

## Usage

Expand Down
1 change: 1 addition & 0 deletions lib/chewy/search/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ def reset

def perform(additional = {})
request_body = render.merge(additional)
request_body[:rest_total_hits_as_int] = true if Runtime.version >= '7.0.0'
ActiveSupport::Notifications.instrument 'search_query.chewy',
notification_payload(request: request_body) do
begin
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/stash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Journal < Chewy::Index
# @param since_time [Time, DateTime] a timestamp from which we load a journal
# @param only [Chewy::Index, Array<Chewy::Index>] journal entries related to these indices will be loaded only
def self.entries(since_time, only: [])
self.for(only).filter(range: {created_at: {gt: since_time}})
self.for(only).filter(range: {created_at: {gt: since_time}}).filter.minimum_should_match(1)
end

# Cleans up all the journal entries until the specified time. If nothing is
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 = '6.0.0'.freeze
VERSION = '7.0.0'.freeze
end
17 changes: 14 additions & 3 deletions migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ This document outlines the steps you need to take when migrating between major v
Chewy and Elasticsearch. For simplicity's sake the guide will assume that you're using
Chewy alongside a matching Elasticsearch version.

## Chewy 6/Elasticsearch 6 to Chewy 7/Elasticsearch 7

In order to upgrade Chewy 6/Elasticsearch 6 to Chewy 7/Elasticsearch 7 in the most seamless manner you have to:

* Upgrade to the latest 6.x stable releases, namely Chewy 6.0, Elasticsearch 6.8
* Study carefully [Breaking changes in 7.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.htmll), make sure your application conforms.
* Run your test suite on Chewy 7 / Elasticsearch 7
* Run manual tests on Chewy 7 / Elasticsearch 7
* Upgrade to Chewy 7
* Perform a [rolling upgrade](https://www.elastic.co/guide/en/elasticsearch/reference//rolling-upgrades.html) of Elasticsearch

## Chewy 5/Elasticsearch 5 to Chewy 6/Elasticsearch 6

In order to upgrade Chewy 5/Elasticsearch 5 to Chewy 6/Elasticsearch 6 in the most seamless manner you have to:
Expand All @@ -17,7 +28,7 @@ In order to upgrade Chewy 5/Elasticsearch 5 to Chewy 6/Elasticsearch 6 in the mo
* replace fields with `{ type: 'string', index: 'analyzed'}` by `{type: 'text'}`
* `PathHierarchy` tokenizer' param `delimiter` now accepts only one argument, [others should be replaced by character filter ](https://discuss.elastic.co/t/multichar-delimiter-in-path-hierarchy-tokenizer/16203)
* Make sure you don't use any other of the [deprecated Elasticsearch 5 features](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html)
* Run your test suite on Elasticsearch 6
* Run manual tests on Elasticsearch 6
* Perform a [rolling upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/rolling-upgrades.html) of Elasticsearch
* Run your test suite on Chewy 6 / Elasticsearch 6
* Run manual tests on Chewy 6 / Elasticsearch 6
* Upgrade to Chewy 6
* Perform a [rolling upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/rolling-upgrades.html) of Elasticsearch
4 changes: 2 additions & 2 deletions spec/chewy/runtime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Chewy::Runtime do
describe '.version' do
specify { expect(described_class.version).to be_a(described_class::Version) }
specify { expect(described_class.version).to be >= '5.6' }
specify { expect(described_class.version).to be < '7.0' }
specify { expect(described_class.version).to be >= '6.8' }
specify { expect(described_class.version).to be < '8.0' }
end
end
4 changes: 3 additions & 1 deletion spec/chewy/search/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,12 @@
outer_payload = payload
end
subject.query(match: {name: 'name3'}).to_a
request = {index: ['products'], type: %w[product], body: {query: {match: {name: 'name3'}}}}
request[:rest_total_hits_as_int] = true if Chewy::Runtime.version >= '7.0.0'
expect(outer_payload).to eq(
index: ProductsIndex,
indexes: [ProductsIndex],
request: {index: ['products'], type: %w[product], body: {query: {match: {name: 'name3'}}}},
request: request,
type: ProductsIndex::Product,
types: [ProductsIndex::Product]
)
Expand Down
5 changes: 3 additions & 2 deletions spec/chewy/search/scrolling_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@
outer_payload << payload
end
request.scroll_batches(batch_size: 3).to_a

request = {index: %w[cities countries], type: %w[city country], body: {sort: ['rating']}, size: 3, scroll: '1m'}
request[:rest_total_hits_as_int] = true if Chewy::Runtime.version >= '7.0.0'
expect(outer_payload).to match_array([
hash_including(
index: [CitiesIndex, CountriesIndex],
indexes: [CitiesIndex, CountriesIndex],
request: {index: %w[cities countries], type: %w[city country], body: {sort: ['rating']}, size: 3, scroll: '1m'},
request: request,
type: [CitiesIndex::City, CountriesIndex::Country],
types: [CitiesIndex::City, CountriesIndex::Country]
),
Expand Down

0 comments on commit 3ba07cc

Please sign in to comment.