Aggregation on childern but filters on parent


(Lokeshhctm) #1

How can the query be optimized:

{
"query": {
"filtered": {
"query": {
"match_all": []
},
"filter": {
"bool": {
"must": [],
"must_not": []
}
}
}
},
"size": 0,
"aggs": {
"details-filter": {
"filter": {
"bool": {
"must": [
{
"terms": {
"Y": [
"10810"
]
}
},
{
"terms": {
"P": [
"121187"
]
}
},
{
"terms": {
"D": [
"T"
]
}
},
{
"terms": {
"H": [
"2"
]
}
}
]
}
},
"aggs": {
"uniques_index": {
"children": {
"type": "u"
},
"aggs": {
"uniques": {
"cardinality": {
"field": "u.userid.hash",
"precision_threshold": 100
}
}
}
}
}
}
}
}

The above query always takes the same time regardless of number of filters i put for parent.
It seems like it always scans the whole data.


(Lokeshhctm) #2

Can somebody help me here please?


(system) #3