Filter on boolean field increases latency and CPU
Finally, I couldn't solve the issue performing the query like I described here...
I solved this creating 2 different document types, according to the TRUE/FALSE value of the related field.
With this approach, no CPU increase, no latency problems... And since ElasticSearch can search in multiple document types at a time, this separation wasn't cause major problems to my application code ;)
So now, I perform the same query in both cases but changing only the document type target:
POST /my_index/doc_type_with_true_value/_searchPOST /my_index/doc_type_with_false_value/_search
{ "from" : 0, "size" : 10, "query" : { "filtered" : { "query" : { "match_all" : { } }, "filter" : { "and" : { "filters" : [ { "bool" : { "must" : [ { "range" : { "_timestamp" : { "from" : null, "to" : "2016-05-04T15:12:00Z", "include_lower" : true, "include_upper" : false } } } ] } }, { "geo_distance" : { "rounded_location" : [ -8.42, 42.24 ], "distance" : "300000m", "distance_type" : "plane", "optimize_bbox" : "indexed" } } ] } } } }, "sort" : [ { "_geo_distance" : { "rounded_location" : [ { "lat" : 42.24, "lon" : -8.42 } ], "unit" : "m" } }, { "date" : { "order" : "desc" } }, { "price" : { "order" : "asc" } } ]}