# Is there a difference between query\_string, wildcard and match?

**URL:** <https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681>\
**Category:** Elasticsearch\
**Created:** [May 14, 2018, 7:45am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681 "2018-05-14T07:45:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomuser](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@randomuser](https://discuss.elastic.co/u/randomuser)\
**Post date:** [May 14, 2018, 7:45am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681/1 "2018-05-14T07:45:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 14, 2018, 9:12am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681/2 "2018-05-14T09:12:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![randomuser](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@randomuser](https://discuss.elastic.co/u/randomuser)\
**Post date:** [May 14, 2018, 9:19am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681/3 "2018-05-14T09:19:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 14, 2018, 9:39am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681/4 "2018-05-14T09:39:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![randomuser](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@randomuser](https://discuss.elastic.co/u/randomuser)\
**Post date:** [May 14, 2018, 9:45am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681/5 "2018-05-14T09:45:18Z")

</div>

Alright, thank you very much! 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 11, 2018, 9:47am UTC](https://discuss.elastic.co/t/is-there-a-difference-between-query-string-wildcard-and-match/131681/6 "2018-06-11T09:47:13Z")

</div>

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