Skip to content

8.15.6 - TermQuery / TermsQuery inconsistencies and feedback #8345

Closed
@niemyjski

Description

@niemyjski

Elastic.Clients.Elasticsearch version: 8.15.6

Elasticsearch version: 8.15.1

.NET runtime version: 8.x

Operating system version: Any

Description of the problem including expected versus actual behavior:

I noticed a lot of inconsistencies / verbosity when converting to the new api's. I feel like the old one was more consistent and easy to use.

Previous

if (ids is { Count: > 0 })
    node.Parent.SetQuery(new TermsQuery { Field = "id", Terms = ids });
else
    node.Parent.SetQuery(new TermQuery { Field = "id", Value = "none" });

New

if (ids is { Count: > 0 })
    node.Parent.SetQuery(new TermsQuery { Field = "id", Term = new TermsQueryField(ids.Select(FieldValue.String).ToArray()) });
else
    node.Parent.SetQuery(new TermQuery("id") { Value = "none" });

Expected behavior
It doesn't make any sense why these are so much different, and all the extra casts (no implicit conversion for field values).

Reference: FoundatioFx/Foundatio.Parsers#84

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions