Hi,
i'm comparing the usage of Constant_score against a bool query and i'm finding that the latter returns more results.
I'm not interested in the scoring of results and hence that why i'm going via the constant score route
Constant_Score Query
GET 2016042*/mytype/_search
{
"size": 0,
"explain": false,
"query": {
"constant_score": {
"filter": {
"term": {
"eCode": "event1"
}
},
"filter": {
"range": {
"@timestamp": {
"gte": "now-2d",
"lte": "now"
}
}
}
}
}
}
Constant Score Result
{
"took": 192,
"timed_out": false,
"_shards": {
"total": 4,
"successful": 4,
"failed": 0
},
"hits": {
"total": 230282,
"max_score": 0,
"hits": []
}
}
Bool Query
GET 2016042*/mytype/_search
{
"size": 0,
"explain": false,
"query": {
"bool": {
"must": [
{
"term": {
"eCode": {
"value": "event1"
}
}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-2d",
"lte": "now"
}
}
}
}
}
}
Bool Query result
{
"took": 165,
"timed_out": false,
"_shards": {
"total": 4,
"successful": 4,
"failed": 0
},
"hits": {
"total": 223736,
"max_score": 0,
"hits": []
}
}
-
Why do the 2 queries return different hits?
Bool Query : 223736 hits
Constant Score Query : 230282 hits ( 7K hits more than Bool Query) -
I was under the impression that the constant score query would perform better. But in this particular scenario, the bool query was faster
In any case, the query will be integrated in a Watcher and that would execute every 5 mins. could there be any issue by virtue of using Constant Score as i understand the query results are cached?
Can someone please help clarify these?
Regards
A.