Skip to content

Is there a recommended way to use CompositeAggregation with kt-search? #175

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
nfa-dev opened this issue Apr 13, 2025 · 1 comment
Open

Comments

@nfa-dev
Copy link

nfa-dev commented Apr 13, 2025

Hi, I'm using kt-search (version 2.0.3) in a Spring Boot project and would like to use CompositeAggregation to paginate over a large result set.

I’ve read through the official documentation here:
https://jillesvangurp.github.io/kt-search/manual/Aggregations.html

But I couldn’t find any documentation or examples related to how to use CompositeAggregation, especially with paging using afterKey.

Why is this needed?

Composite aggregation is the recommended way in Elasticsearch to get accurate distinct field values for large sets,
but it's tricky to implement correctly without guidance on how to handle afterKey and buckets safely across pages.

Could you provide any guidance or a working example?

Thanks for the awesome DSL!

@jillesvangurp
Copy link
Owner

I don't currently have any support for that and it looks like it's a relatively new feature that I haven't used yet myself. You should be able by just accessing the JsonDsl map directly. Or you could create a PR that adds the support if you feel up to it.

BTW. Using this in combination with a large result set sounds like it could be expensive.

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

No branches or pull requests

2 participants