Skip to content

Elasticsearch::Client unexpectedly modifies parameters during search #1727

@j-bennet

Description

@j-bennet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions