elastic4s icon indicating copy to clipboard operation
elastic4s copied to clipboard

Support for custom aggregations

Open joelvim opened this issue 3 years ago • 1 comments

We have a custom plugin defining our own aggregation. Currently we are using a modified version of elastic4s 5.6.x where we implemented the support for our custom aggregation like any other elastic standard aggregation.

In the process of migrating to Elasticsearch 8, we are trying to remain on a standard version of elastic4s, but we did not find a way to support custom aggregations. The aggregation builder function is a static pattern match that will fail in case an aggregation is not known. That prevents support of custom aggregations.

We were thinking on adding this support. An idea we had was to introduce a parameter in the AggregationBuilderFn.apply of type PartialFunction[AbstractAggregation, XContentBuilder] or similar and this parameter would bubble up to SearchHandler that would become a class taking the partial function as (implicit?) parameter, and a default instance would take the default current behaviour that throws a NotImplementedError.

What do you think about something like this? We could do a PR and iterate over it.

joelvim avatar Sep 15 '22 13:09 joelvim

You would need to break the type signature, but if the parameter was implicit, and a default implicit was provided, I think it would be ok. So yeah lets PR it and see.

sksamuel avatar Sep 17 '22 16:09 sksamuel

Ok let's do it, thanks.

joelvim avatar Sep 19 '22 07:09 joelvim

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 24 '22 00:12 stale[bot]