crnk-project / crnk-framework

JSON API library for Java
Apache License 2.0
289 stars 154 forks source link

Faceted Search: Other aggregations than "count"? #574

Open nwinkler opened 4 years ago

nwinkler commented 4 years ago

While using the new Faceted Search feature, I saw that it currently only supports counting the items that were grouped. Are there plans for supporting other kinds of aggregations like SUM or something like that?

My use case is that in addition to counting items in specific buckets (= facets), I might also have to sum up the values of a specific field in my entity, e.g. an amount field - similar to how I would use SUM(amount) together with GROUP BY accountID in SQL.

Please let me know if you need more information about my use case.

remmeier commented 4 years ago

in principal nothing is holding this back. The one thing currently missing is the information after what to "summ up". Could be a parameter to the request, or could be something predefined with annotations.

nwinkler commented 4 years ago

Thanks for the quick response. I'd prefer a parameter, since that would enable somewhat dynamic requests. You'd still have to implement the query in the backend for your data storage provider (think something like ElasticSearch, or similar)...

remmeier commented 4 years ago

Maybe similar to FilterOperator.SELECT and FilterOperator.GROUP (filter[values][GROUP]=priority,name) one could introduce an additional aggregation parameter to define the aggregation mechanism. Not yet quite sure how it could exactly look like.

nwinkler commented 4 years ago

Yes, that's what I thought as well.

remmeier commented 4 years ago

in the backend for your data storage provider (think something like ElasticSearch, or similar)

PRs would be welcomed if you have time. Also should you have something in the Elastic area. We make use of it as well. But so far did not do anything in that direction, but likely would then also end up doing so.

nwinkler commented 4 years ago

Nothing for ES so far. I've actually been playing around with Redisearch, this worked quite well with the faceted search... ES should work in a similar way, I assume.