I'm working on implementing a group-by functionality in my React app using Elastic's search-ui and running into some roadblocks. I've tried multiple approaches to achieve grouping and aggregations, but none have worked as expected.
I tried using the group property in the search query. While this does group the results, it only returns between 1 to 10 documents per group, which isn’t sufficient for my use case where I need all items associated with each group.
I also tried to pass the aggs and aggregations property but this ended up in an Error: [400] Options contains invalid key: aggs
At this point, it seems like search-ui's App Search integration may not fully support the advanced grouping and aggregation features I need, but I’m hoping there might be a workaround.
When I refer to grouping, I mean organizing the search results by a shared attribute, such as a tag or category. The idea is to have results displayed in distinct sections based on that shared field. Each section (or group) would have a heading corresponding to the tag/category (e.g., "Tag 1", "Tag 2"), and underneath, all the related items would be listed.
Grouping Example:
Group by a Field: Results are grouped by a field like tags or category. Each group contains all items that share that specific field value.
Visual Layout: The results are displayed in different sections, each labeled with the group's field (e.g., "Tag 1" at the top of one section, "Tag 2" at the top of another).
Clear Separation of Groups: Each group is clearly separated from the others, making it easy to navigate through the data.
The Core Issue:
My problem isn’t how to implement this in React (which is straightforward). The main challenge is how to get the data grouped directly from Elastic App Search. App Search doesn't seem to support grouping or aggregations in the same way as Elasticsearch’s native queries do. For instance, using the group property in App Search only returns 1 to 10 items per group, which isn't sufficient for my needs.
I’m looking for a way to get all the items related to each group from Elastic App Search, but without running into these limitations. Do you have any suggestions on how to proceed with grouping in App Search, or would a switch to native Elasticsearch be required to achieve this functionality?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.