Skip to content

msearch overriding headers so compatible-with=8 cannot be set #2758

@felixstackadapt

Description

@felixstackadapt

Describe the bug/error/problem
We are currently trying to update the 9.0.3 version of the gem. Our server is running 8.6.2. We were getting this error for our request

[400] {"error":{"root_cause":[{"type":"media_type_header_exception","reason":"Invalid media-type value on headers [Accept, Content-Type]"}],"type":"media_type_header_exception","reason":"Invalid media-type value on headers [Accept, Content-Type]","caused_by":{"type":"status_exception","reason":"Accept version must be either version 8 or 7, but found 9. Accept=application/vnd.elasticsearch+json; compatible-with=9"}},"status":400} 

so we have added the compatible-with=8 transport_options headers to Elasticsearch::Client.new to fix

accept: 'application/vnd.elasticsearch+json; compatible-with=8', content_type: 'application/vnd.elasticsearch+json; compatible-with=8' 

This has fixed our search requests but not msearch as the headers we set before calling msearch gets overridden by msearch itself.

looking at msearch source code it looks like msearch add compatible-with=9 to the headers which overrides the ones we set.

headers.merge!({ Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' }) 

is there a way we can set msearch headers to be compatible-with=8

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