I understand that named queries add the matched_queries property to the response, but is there any way to access documents that match the named queries in aggregations?
The goal is to be able to use the "%dashboard_context-must_clause%" for dynamic time ranges, but I haven't been able to find a way to do bool queries inside of aggregations.
"query": {
"bool": {
"must": [
{"match": {"year-month": {"query": "2021-01", "_name": "A"}}},
{"match": {"year-month": {"query": "2021-03", "_name": "B"}}}
]
}
},
"aggs": {
"calcs": {
"terms": {
"script": "'do stuff'"
},
"aggs": {
"A_calc":{
//I want to only use the results from query A here
"filter": { "term": { "meat":"steak" } },
"aggs" : {
"steakcount": {
"value_count": {
"field": "meat"
}
}
}
},
"B_calc":{
//I want to only use the results from query B here
"filter": { "term": { "meat":"chicken"} },
"aggs" : {
"chickencount": {
"value_count": {
"field": "meat"
}
}
}
},