Is there a difference between query_string, wildcard and match?

Hello guys,

I've created a few variations of a query and tried out different searching approaches, I seem to be getting the same results, so it got me wondering are there any differences (e.g. performance wise) between the following:

  "query": {
    "query_string": {
      "default_field": "hardware", 
      "query" : "*laptop*"
    }
  }

  "query": {
    "match": { 
      "hardware": "laptop"
    }
  }

  "query": {
    "wildcard": { 
      "hardware.standard": {
        "value": "*laptop*"
      }
    }
  }

yes, there are, because the first and last query searches for terms that contain laptop anywhere in their string (potentially causing the check out all the terms in an index), where as the second variant just searches for documents containing the word laptop as a whole. The difference can be massive.

Yeah, the second works the same no matter if I add asterisks or not, so I left it out.
Lets ignore the match query then, between the query_string and wildcard query, is there any difference except the syntax? Which one is faster?

no, not really. Both are going can be slow on bigger datasets. You might want to look into ngrams, edgengrams or the compound token filter as soon as you run into speed issues.

Alright, thank you very much! :smiley:

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