Performance of filtered wildcard queries

Hi all,

I have a very simple index structure only containing the fields (project_id:int and name:string). What I want to do is a wildcard (infix) query on the name field and that scoped with the project_id. What I am using for this is this search:

{
  "query": {
    "bool": {
      "must": [
        { "wildcard": { "name": "*test*" } }
      ],
      "filter": [
        {
          "term": { "project_id": 4711 }
        }
      ]
    }
  }
}

The problem is, no matter how many documents are selected by the project_id filter, the initial queries for the wildcard always take ~ 200ms (having 17mio records in the index). That even happens when the filter does not select any documents at all (like when using -1 for the project ID).

Is there anything I can do to make those initial queries to perform better?

As written in documentation wildcards queries are very slow.
Better to use ngram strategy if you want it to be fast at query time.

What happens if you remove the must part?

Could you turn profile on to see where it is slow?

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