- Notifications
You must be signed in to change notification settings - Fork 614
Closed
Description
When calling search
method of Elasticsearch::Client
and passing in a dict of parameters, parameters are unexpectedly modified. Here is a minimal example:
require 'elasticsearch' require 'awesome_print' class MyQueueSearch attr_accessor :index attr_accessor :client def initialize self.index = 'my_test_index' self.client = Elasticsearch::Client.new(:user => 'elastic', :password => 'changeme') end def search search_args = { :index => self.index, :body => { :_source => false, :seq_no_primary_term => true, :query => { :bool => { :filter => { :term => { :status => 'pending' } } } } } } puts("Search args before:") ap(search_args) res = self.client.search(search_args) puts('-' * 40) puts("Search args after:") ap(search_args) end def create_index self.client.indices.delete(:index => self.index, :ignore_unavailable => true) self.client.indices.create(:index => self.index) self.client.index(:index => self.index, :id => "1", :body => {'status' => 'pending'}) end def run create_index search end end s = MyQueueSearch.new s.run
Output:
Search args before: { :index => "my_test_index", :body => { :_source => false, :seq_no_primary_term => true, :query => { :bool => { :filter => { :term => { :status => "pending" } } } } } } ---------------------------------------- Search args after: { :index => "my_test_index" }
If I needed my params after, this is breaking behavior.
The behavior changed between 7.17 and 8.0.
ioanatia