I am looking a way where I can apply condition on value return in result. Here is my query.
{
"size": 0,
"aggs": {
"by_brand": {
"terms": {
"field": "brand_name.keyword",
"size": 10000,
"order": {
"_key": "asc"
},
"min_doc_count": 50
},
"aggs": {
"product": {
"cardinality": {
"field": "product_id"
}
}
}
}
},
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['image_src.keyword'].size()!=0",
"lang": "painless"
}
}
}
}
}
}
and my result is as follow
{
"took" : 150,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"by_brand" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "4SI3NNA",
"doc_count" : 432,
"product" : {
"value" : 119
}
},
{
"key" : "525 America",
"doc_count" : 706,
"product" : {
"value" : 83
}
},
{
"key" : "7 For All Mankind",
"doc_count" : 3558,
"product" : {
"value" : 555
}
},
{
"key" : "AG",
"doc_count" : 3657,
"product" : {
"value" : 464
}
},
{
"key" : "AGOLDE",
"doc_count" : 501,
"product" : {
"value" : 85
}
},
{
"key" : "AS by DF",
"doc_count" : 997,
"product" : {
"value" : 324
}
}
]
}
}
}
I like to filter out those result which have product->value less then 50.
{
"key" : "AS by DF",
"doc_count" : 997,
"product" : {
"value" : 324
}
}
Thanks in advance
Regards