Skip to content

SearchRequest cannot parse _source correctly #1245

Description

@aidin-gh

Java API client version

9.4.2

Java version

17

Elasticsearch Version

9.4.2

Problem description

Issue

I'm parsing a JSON ES DSL query using the SearchRequest.of method. The _source field is a list of columns. This is a valid ES DSL query, and I can run it on Elasticsearch. However, the SearchRequest.of throws this error:

co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.core.SearchRequest: Cannot determine what union member to deserialize (JSON path: _source) (line no=1, column no=142, offset=141)

If I change the _source from:

"_source":["date","distributor" ...

to:

"_source":{"includes":["date","distributor" ...

It can parse it.

Expected Outcome

Having a list in _source is a valid ES DSL query. SearchRequest should be able to parse it.

Reproduction

Here's a minimal project that reproduces the issue: https://github.com/aidin-gh/elasticsearch-source-parsing-error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions