@random_user_qna Welcome to the Elastic community!!
I think aggs with global aggregation is good enough. Here is the quick poc
POST _bulk
{ "index": { "_index": "watches", "_id": 1 } }
{ "name": "Titan Leather Watch", "gender": "Men", "brand": "Titan", "strap_material": "Leather", "price": 2500 }
{ "index": { "_index": "watches", "_id": 2 } }
{ "name": "Sonata Plastic Watch", "gender": "Women", "brand": "Sonata", "strap_material": "Plastic", "price": 1800 }
{ "index": { "_index": "watches", "_id": 3 } }
{ "name": "Fastrack Silicone Watch", "gender": "Unisex", "brand": "Fastrack", "strap_material": "Silicone", "price": 2200 }
{ "index": { "_index": "watches", "_id": 4 } }
{ "name": "Kenneth Cole Bimetal Watch", "gender": "Couple", "brand": "Kenneth Cole", "strap_material": "Bimetal", "price": 7500 }
{ "index": { "_index": "watches", "_id": 5 } }
{ "name": "Tommy Hilfiger Leather Watch", "gender": "Girls", "brand": "Tommy Hilfiger", "strap_material": "Leather", "price": 6500 }
{ "index": { "_index": "watches", "_id": 6 } }
{ "name": "SF 18 Karat Gold Watch", "gender": "Guys", "brand": "SF", "strap_material": "18 Karat Gold", "price": 10500 }
{ "index": { "_index": "watches", "_id": 7 } }
{ "name": "Zoop Acetate Watch", "gender": "Kids", "brand": "Zoop", "strap_material": "Acetate", "price": 1200 }
{ "index": { "_index": "watches", "_id": 8 } }
{ "name": "Titan Acetate & Metal Watch", "gender": "Men", "brand": "Titan", "strap_material": "Acetate & Metal", "price": 8000 }
{ "index": { "_index": "watches", "_id": 9 } }
{ "name": "Sonata Plastic Strap Watch", "gender": "Women", "brand": "Sonata", "strap_material": "Plastic", "price": 2100 }
{ "index": { "_index": "watches", "_id": 10 } }
{ "name": "Fastrack Leather Watch", "gender": "Unisex", "brand": "Fastrack", "strap_material": "Leather", "price": 3500 }
GET watches/_search
{
"size": 0,
"query": {
"match": {
"name": "Titan"
}
},
"aggs": {
"genders": {
"terms": {
"field": "gender.keyword"
}
},
"brands": {
"terms": {
"field": "brand.keyword"
}
},
"strap_materials": {
"global": {},
"aggs": {
"materials": {
"terms": {
"field": "strap_material.keyword"
}
}
}
}
}
}
Response
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"genders": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Men",
"doc_count": 2
}
]
},
"brands": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Titan",
"doc_count": 2
}
]
},
"strap_materials": {
"doc_count": 10,
"materials": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Leather",
"doc_count": 3
},
{
"key": "Plastic",
"doc_count": 2
},
{
"key": "18 Karat Gold",
"doc_count": 1
},
{
"key": "Acetate",
"doc_count": 1
},
{
"key": "Acetate & Metal",
"doc_count": 1
},
{
"key": "Bimetal",
"doc_count": 1
},
{
"key": "Silicone",
"doc_count": 1
}
]
}
}
}
}
Here the strap_material
facets remains unchanged.