Best caching strategy: filter only vs filtered query with _cache:true

I wonder what is the best solution for an autocomplete/lookup type of solution when we don't care for score.

We have an index with accounts per customers where the account number is analyzed by edgeNGram and the account name by nGram.

As I can see, I have the following options:

  • Filtered query with _cache: true and constant_score query:

"query" : { "filtered" : { "filter" : { "bool" : { "_cache" : true, "must" : [{ "term" : { "customer" : "xyz" } } ], "must_not" : [{ "term" : { "inactive" : true } } ] } }, "query" : { "constant_score" : { "query" : { "bool" : { "should" : [{ "term" : { "acc_no" : "123" } }, { "term" : { "acc_name" : "123" } } ] } } } } } }

  • Filter only and let elastic handle the caching

"filter": { "bool": { "must": [ { "term": { "customer": "xyz" } } ], "must_not": [ { "term": { "inactive": true } } ], "should": [ { "term": { "acc_no": "123" } }, { "term": { "acc_name": "123" } } ] } }

My problem with using the _cache: true is that I think that the customer filter will not be reused for other type of searches (projects etc) while the filter only will cache too much (?). Any inputs?

We are on 1.7.5 for now.

Thanks