elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

ElasticSearch incorrecly serialize percolated queries

Open KondzioSSJ4 opened this issue 6 months ago • 8 comments

Elastic.Clients.Elasticsearch version: 8.11 (latest)

Elasticsearch version: 8.11.3 (latest)

.NET runtime version: 6

Operating system version: Windows 11

Description of the problem including expected versus actual behavior: Percolated queries in Elastic Search doesn't serialized to correct value

For example simple query like:

Query.Terms(new TermsQuery()
{
    Field = Item.GetExpression(x => x.Name1),
    Terms = new TermsQueryField(new[] { FieldValue.String("value") })
})

when converted to percolated query in index it will provide:

"query":{"terms":{"name1":{}}}

What is incorrect, because it should converted to:

"query":{"terms":{"name1":["value"]}}

Steps to reproduce: Go to repository: https://bitbucket.org/KondzioSSJ4/es_percolatedserialization/src/meh/

And then just run any of this projects each of them returns error when try to index data

Expected behavior Percolated queries would correctly indexed in elastic

Provide ConnectionSettings (if relevant): localhost... any Docker would be helpfull

Provide DebugInformation (if relevant):

Invalid Elasticsearch response built from a unsuccessful (400) low level call on PUT: /percolated-index/_doc/3df093da-1f93-487f-b2bc-5616a33f2a56
 Exception: Request failed to execute. Call: Status code 400 from: PUT /percolated-index/_doc/3df093da-1f93-487f-b2bc-5616a33f2a56. ServerError: Type: document_parsing_exception Reason: "[1:79] failed to parse: Required [index, id, path]" CausedBy: "Type: illegal_argument_exception Reason: "Required [index, id, path]""

# Audit trail of this API call:
 - [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.0266196
# OriginalException: Elastic.Transport.TransportException: Request failed to execute. Call: Status code 400 from: PUT /percolated-index/_doc/3df093da-1f93-487f-b2bc-5616a33f2a56. ServerError: Type: document_parsing_exception Reason: "[1:79] failed to parse: Required [index, id, path]" CausedBy: "Type: illegal_argument_exception Reason: "Required [index, id, path]""
# Request:
{"dingerId":"3df093da-1f93-487f-b2bc-5616a33f2a56","query":{"terms":{"name1":{}}}}
# Response:
{"error":{"root_cause":[{"type":"document_parsing_exception","reason":"[1:79] failed to parse: Required [index, id, path]"}],"type":"document_parsing_exception","reason":"[1:79] failed to parse: Required [index, id, path]","caused_by":{"type":"illegal_argument_exception","reason":"Required [index, id, path]"}},"status":400}

KondzioSSJ4 avatar Dec 18 '23 19:12 KondzioSSJ4