Hi,
Generally it is recommended to use filters for optimal performance, but I am getting 5 times more latency when using filters compared to bool query.
However for me it does not make sense to use bool as logically I inly have to filter.
The queries are
GET entity/entity/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"terms": {
"type": [
"tags"
]
}
},
{
"terms": {
"state": [
0
]
}
}
]
}
},
{
"bool": {
"should": [
{
"prefix": {
"name": {
"value": "a"
}
}
},
{
"prefix": {
"ID": {
"value": "a"
}
}
}
]
}
}
]
}
}
}
The other query is
GET entity/entity/_search
{
"query": {
"bool": {
"should": [
{
"prefix": {
"name": {
"value": "a"
}
}
},
{"prefix": {
"ID": {
"value": "a"
}
}
}
],
"filter": [
{ "term": { "type": "tags" }},
{"term":{"state":0}}
]
}
}
}
The filter query is comes out in 3 seconds and bool query takes 300-400 ms.
The total number of hits differ significantly with a 10K on filter query and 500 on bool query.
Total documents on entity index are 150 million.
Why does filter query have more number of hits then bool query and bad performance ?