Skip to content

TermQueryConverter is failing to deserialize string value #8432

@MikeAlhayek

Description

@MikeAlhayek

Elastic.Clients.Elasticsearch version:
8.16.3

Elasticsearch version:
8.6.1

.NET runtime version:
.net9

Description of the problem including expected versus actual behavior:

I am trying to deserialize the following query:

{
  "query": {
    "term": { "Content.ContentItem.ContentType": "BlogPost" }
  },
  "size": 3
}

This query string is being deserialized using the SourceSerializer like this:

using var stream = new MemoryStream(Encoding.UTF8.GetBytes(query));
var request = _client.SourceSerializer.Deserialize<SearchRequest>(stream);

However, the code above fails to deserialize the value of the term query when it is provided as a string.

The following query works as expected:

{
  "query": {
    "term": { "Content.ContentItem.ContentType": { "value": "BlogPost" } }
  },
  "size": 3
}

Steps to reproduce:

  1. Try to deserialize the query listed above using the code.

Expected behavior
I expect that the value will be deserialize from a string or from an object.

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