Skip to content

Improve usability of FiltersAggregation #8242

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

Open
Tracked by #8356
flobernd opened this issue Jun 19, 2024 · 3 comments
Open
Tracked by #8356

Improve usability of FiltersAggregation #8242

flobernd opened this issue Jun 19, 2024 · 3 comments

Comments

@flobernd
Copy link
Member

Currently it's only possible to use Anonymous Filters with the FiltersAggregation:

var q = await client.SearchAsync<Person>(s => s
    .Aggregations(aggs => aggs
        .Add("my_agg", agg => agg
            .Filters(a => a.Filters(new Buckets<Query>([
                Query.MatchAll(new MatchAllQuery()),
                Query.MatchAll(new MatchAllQuery())
            ])))
        )
    )
);

Using named filters throws an exception during deserialization of the results:

var q = await client.SearchAsync<Person>(s => s
    .Aggregations(aggs => aggs
        .Add("my_agg", agg => agg
            .Filters(a => a.Filters(new Buckets<Query>(new Dictionary<string, Query> // <- Dictionary instead of Array
            {
                { "a", Query.MatchAll(new MatchAllQuery()) },
                { "b", Query.MatchAll(new MatchAllQuery()) }
            })))
        )
    )
);

To improve usability, we have to automatically set the keyed argument to true, if the user requests named results.

Besides that, FiltersBucket currently misses the key field in the specification.

Related to #7844

@hubilation
Copy link

Worth noting that NEST treated these as separate operations. "Filters" vs "NamedFilters". Coming across this threw a wrench in our migration efforts.

@braveyp
Copy link

braveyp commented Sep 19, 2024

Is there a roadmap / timeframe for when this will be implemented? I know there's a workaround to simply not use named filters but wasn't sure of the position of the 'other' bucket in the results.

Also, is there a time frame for when a fluent interface will be added for the specification of filter queries?

@flobernd
Copy link
Member Author

Is there a roadmap / timeframe for when this will be implemented? I know there's a workaround to simply not use named filters but wasn't sure of the position of the 'other' bucket in the results.

I'm currently in the procress of prioritizing the "usability" issues. Btw.: The order of the resulting buckets is always the same as for the input ones. Overflow/other should be on the very end.

Also, is there a time frame for when a fluent interface will be added for the specification of filter queries?

This is currently tracked in #7812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants