Bool term filter slow

I have a bool query with a filter that took ~260ms. If I simply remove the filter (just a term filter) the query take ~60ms.

The index has around 16Mill of docs and the filters takes out around 1Mill. it's possible that the filter doesn't use the cache so it's so slow ?

I have done a _profile to the query:

   "type": "TermQuery",
    "description": "situacion:x",
     "time": "219.7595780ms",
      "time_in_nanos": 219759578,
            "breakdown": {
               "score": 0,
                "build_scorer_count": 66,
                "match_count": 0,
                "create_weight": 1560,
                "next_doc": 216418252,
                "match": 0,
                "create_weight_count": 1,
                "next_doc_count": 2810343,
                "score_count": 0,
                "build_scorer": 529356,
                "advance": 0,
                "advance_count": 0
            }

the more expensive is the next_doc but I really doesn't known what this means and how to optimize it.

If I put the filter in a post_filter top field, the query run fast:

   "query": { 
      "bool": {... 
           }
   }, 
   "post_filter": {
      "term": { ... } 
    }

Is this the way to go?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.