Is there a difference between query_string, wildcard and match?


#1

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*"
      }
    }
  }

(Alexander Reelsen) #2

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.


#3

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?


(Alexander Reelsen) #4

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.


#5

Alright, thank you very much! :smiley:


(system) #6

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