I have an Elasticsearch Index setup with the following document structure.
NOTE: THIS IS BEING DONE USING APP SEARCH SO I'm UNABLE TO USE NESTED FIELDS
[
{
"id":id,
"title: "Sample Title",
"created_at":timestamp
"categories:[
{
"name": "Category 1"
"image": "image.png",
},
{
"name": "Category 2"
"image": "image.png",
},
{
"name": "Category 3"
"image": "image.png",
},
{
"name": "Category 4"
"image": "image.png",
},
....
]
},
....
]
This index will contain hundreds of thousands of records in this format.
I'm trying to figure out how to optimally setup a query and structure this data so I can setup a query that will allow me to display a list of categories to the end user in this fashion.
- [image] Category 1 (20)
- [image] Category 2 (30)
- [image] Category 3 (10)
This query would be able to be filtered by the created_at timestamp so that the counts would adjust based on the number of items like such.
- [image] Category 1 (10)
- [image] Category 2 (5)
- [image] Category 3 (25)
Using Aggregations to accomplish this gets me very close, but I'm unable to figure out what the category image would be because the aggregations don't bring back anything but a single value and the count.
Thank you!