-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elasticsearch::Persistence find_in_batches causes BadRequest reason unrecognized token #693
Comments
Same problem for find_each here |
Wonder if this should remain opened, as the Gemfile dependencies refer to a possibly incompatible 6.0.0 version in the future:
|
I have write this hook using the versions mentioned in this issue. If this changes are in the new # config/initializers/hook_elasticsearch.rb
#
# Bug not solved in version 5.0.3 but in master
# https://github.com/elastic/elasticsearch-ruby/blob/master/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb
module Elasticsearch
module API
module Actions
def scroll(arguments={})
method = HTTP_GET
path = "_search/scroll"
valid_params = [
:scroll,
:scroll_id ]
params = Utils.__validate_and_extract_params arguments, valid_params
body = arguments[:body]
perform_request(method, path, params, body).body
end
end
end
end
# Bug not solved in version 0.1.9
# https://github.com/elastic/elasticsearch-rails/commit/e81fc5b5d0648280fdf054566823e647352b45eb
module Elasticsearch
module Persistence
module Model
module Find
module ClassMethods
def find_in_batches(options={}, &block)
return to_enum(:find_in_batches, options) unless block_given?
search_params = options.extract!(
:index,
:type,
:scroll,
:size,
:explain,
:ignore_indices,
:ignore_unavailable,
:allow_no_indices,
:expand_wildcards,
:preference,
:q,
:routing,
:source,
:_source,
:_source_include,
:_source_exclude,
:stats,
:timeout)
scroll = search_params.delete(:scroll) || '5m'
body = options
# Get the initial batch of documents and the scroll_id
#
response = gateway.client.search( { index: gateway.index_name,
type: gateway.document_type,
scroll: scroll,
sort: ['_doc'],
size: 20,
body: body }.merge(search_params) )
# Scroll the search object and break when receiving an empty array of hits
#
while response['hits']['hits'].any? do
yield Repository::Response::Results.new(gateway, response)
response = gateway.client.scroll( { scroll_id: response['_scroll_id'].to_s, scroll: scroll } )
end
return response['_scroll_id']
end
end
end
end
end
end |
I've updated the dependencies in the .gemspec, and fixed the failing integration tests, which are now passing for me locally. |
@karmi The working version was in master.
|
Closing as this is no longer relevant. |
Hi!
I use:
and if I want to
find_in_batches
I get this error:The problem comes from this line in persistence/model/find.rb#L135
response = gateway.client.scroll( { scroll_id: response['_scroll_id'], scroll: scroll } )
Any idea what can be the problem?
[SOLUTION] Bug is solved in master repository of elasticsearch-ruby but not in version 5.0.3.
The text was updated successfully, but these errors were encountered: