Skip to content

Commit

Permalink
Testing on ES7
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Rabotyaga committed Feb 18, 2021
1 parent 47ad295 commit 2588fa0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 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
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
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 2588fa0

Please sign in to comment.