Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use descriptors to set Fields in MultiMatchQueryDescriptor query #8013

Open
ashitanojoe opened this issue Jan 17, 2024 · 2 comments
Labels
8.x Relates to 8.x client version Category: Feature Usability

Comments

@ashitanojoe
Copy link
Contributor

ashitanojoe commented Jan 17, 2024

Is your feature request related to a problem? Please describe.
When trying to migrate our Nest code to the new client I ran into a problem migrating a Multimatch query. In Nest, we could use descriptors to set with fields the multimatch should use for the query. This is not available in the new client, forcing me to use magic strings.

Here is the MultiMatch portion of the query using the new client, with the Nest code commented out.

.MultiMatch(mm => mm
    .Type(TextQueryType.BestFields)
    .Fields(new[]
    {
        "name.lownerngram",
        "tags.lowerekeyword"
    })
    //.Fields(fds => fds
    //    .Field(f => f.Name.Suffix("lowerngram"))
    //    .Field(f => f.Tags.Suffix("lowerkeyword"))
    //)
    .Query(queryString)
)

Describe the solution you'd like
Would like to use descriptors to set the fields the multimatch query will use in a way similar to the commented out code.

@flobernd flobernd added the 8.x Relates to 8.x client version label Jan 17, 2024
@flobernd
Copy link
Member

Hi @ashitanojoe ,

This is one of the features I definitely plan to bring back. I sadly can't give you an ETA.

As a workaround, the Field type can be constructed like this:

Field<TDocument>(f => f.Name)

which allows for:

.MultiMatch(mm => mm
    .Type(TextQueryType.BestFields)
    .Fields(new[]
    {
        Field<TDocument>(f => f.Name),
        Field<TDocument>(f => f.Tags)
    })
    .Query(queryString)
)

I'm not sure, if .Suffix() is implemented already, but you could create your own extension method for the Field class in order to support this functionality, if it's not yet implemented.

@ashitanojoe
Copy link
Contributor Author

Hi @flobernd ,

Thank you for pointing out the workaround. Not sure how I missed that. I definitely like that better than passing a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version Category: Feature Usability
Projects
None yet
Development

No branches or pull requests

2 participants