Listing:
item_id
seller_id
price
I want to group together all listings for the same item, and show the average price across all sellers.
I'm using field collapsing on item_id, but is there a way to to compute the average price of all items collapsed together?
"collapse": {
"field": "item_id",
"inner_hits": {
"name": "hits",
"size": 200
}
},
I started off bucketing by item_id and applying aggregations, but the cardinality of top_hits is sometimes large and queries are very slow, so I'm looking for optimizations and wondering if field collapsing could offer the same functionality.