# Query string query: default fuzziness?

**URL:** https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788
**Category:** Elasticsearch
**Created:** [September 17, 2018, 8:22am UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788 "2018-09-17T08:22:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kasscharal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kasscharal/32/20001_2.png) [@kasscharal](https://discuss.elastic.co/u/kasscharal)
#### Post date: [September 17, 2018, 8:22am UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788/1 "2018-09-17T08:22:39Z")

</div>

Hello people,

I'm using ES for quite a while but I'm stuck on something I cannot explain. I do a simple query like:

> {  
> "query": {  
> "query\_string" : {  
> "query" : "daan"  
> }  
> }  
> }

having all settings on default, and I get back results with the term 'dans' instead of 'daan'. I was under the impression that I had to use ~ in order to enable fuzziness, and that by default I would only get exact matches. Isn't that the case? If not, how can I require exact matches with query string queries? Thank you!

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [September 17, 2018, 10:49am UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788/2 "2018-09-17T10:49:06Z")

</div>

Use the [explain API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html) to figure out what terms/fields are being matched for the docs in question.  
If you have trouble interpreting the output paste it here.

---

<div class="post-metadata">

### Author: ![kasscharal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kasscharal/32/20001_2.png) [@kasscharal](https://discuss.elastic.co/u/kasscharal)
#### Post date: [October 2, 2018, 11:43am UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788/3 "2018-10-02T11:43:14Z")

</div>

Hi @Mark_Harwood!  
I used the explain API for one case without exact matches like this:

```
GET my-index/test/58de9cf6bfcd0b7cf3ab29d8/_explain
{"query": {
  "function_score" : {
    "query" : {
      "bool" : {
        "must" : [
          {
            "query_string" : {
              "query" : "daan",
              "fields" : [
                "match_education^1.0",
                "match_experience^2.0",
                "match_personal^1.0",
                "match_skill^2.0"
              ]
            }
          }
        ]
      }
    }
  }
}
}

```

and I got back:

```
{
  "_index": "my-index",
  "_type": "test",
  "_id": "58de9cf6bfcd0b7cf3ab29d8",
  "matched": true,
  "explanation": {
    "value": 26.325321,
    "description": "sum of:",
    "details": [
      {
        "value": 26.325321,
        "description": "sum of:",
        "details": [
          {
            "value": 26.325321,
            "description": "max of:",
            "details": [
              {
                "value": 10.659221,
                "description": "weight(match_education:dan in 38031) [PerFieldSimilarity], result of:",
                "details": [
                  {
                    "value": 10.659221,
                    "description": "score(doc=38031,freq=1.0 = termFreq=1.0\n), product of:",
                    "details": [
                      {
                        "value": 7.654514,
                        "description": "idf(docFreq=33, docCount=70689)",
                        "details": []
                      },
                      {
                        "value": 1.3925406,
                        "description": "tfNorm, computed from:",
                        "details": [
                          {
                            "value": 1,
                            "description": "termFreq=1.0",
                            "details": []
                          },
                          {
                            "value": 1.2,
                            "description": "parameter k1",
                            "details": []
                          },
                          {
                            "value": 0.75,
                            "description": "parameter b",
                            "details": []
                          },
                          {
                            "value": 12.864208,
                            "description": "avgFieldLength",
                            "details": []
                          },
                          {
                            "value": 4,
                            "description": "fieldLength",
                            "details": []
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "value": 26.325321,
                "description": "weight(match_experience:dan in 38031) [PerFieldSimilarity], result of:",
                "details": [
                  {
                    "value": 26.325321,
                    "description": "score(doc=38031,freq=5.0 = termFreq=5.0\n), product of:",
                    "details": [
                      {
                        "value": 2,
                        "description": "boost",
                        "details": []
                      },
                      {
                        "value": 6.6921854,
                        "description": "idf(docFreq=85, docCount=68919)",
                        "details": []
                      },
                      {
                        "value": 1.9668703,
                        "description": "tfNorm, computed from:",
                        "details": [
                          {
                            "value": 5,
                            "description": "termFreq=5.0",
                            "details": []
                          },
                          {
                            "value": 1.2,
                            "description": "parameter k1",
                            "details": []
                          },
                          {
                            "value": 0.75,
                            "description": "parameter b",
                            "details": []
                          },
                          {
                            "value": 64.27036,
                            "description": "avgFieldLength",
                            "details": []
                          },
                          {
                            "value": 20.897959,
                            "description": "fieldLength",
                            "details": []
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "value": 0,
        "description": "match on required clause, product of:",
        "details": [
          {
            "value": 0,
            "description": "# clause",
            "details": []
          },
          {
            "value": 1,
            "description": "_type:talent, product of:",
            "details": [
              {
                "value": 1,
                "description": "boost",
                "details": []
              },
              {
                "value": 1,
                "description": "queryNorm",
                "details": []
              }
            ]
          }
        ]
      }
    ]
  }
} 

```

My surprise is that it matches: 'dan' instead of 'daan'. Why would that be?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [October 2, 2018, 12:58pm UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788/4 "2018-10-02T12:58:04Z")

</div>

> [@kasscharal](#):
>
> Why would that be?

Your choice of Analyzer dictates how documents and queries are sliced into tokens.  
Can you supply the results of `GET my-index/_mapping`

---

<div class="post-metadata">

### Author: ![kasscharal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kasscharal/32/20001_2.png) [@kasscharal](https://discuss.elastic.co/u/kasscharal)
#### Post date: [October 2, 2018, 2:29pm UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788/5 "2018-10-02T14:29:32Z")

</div>

Oh yes! Makes total sense now!  
Thank you for your time @Mark_Harwood

---

<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: [October 30, 2018, 2:29pm UTC](https://discuss.elastic.co/t/query-string-query-default-fuzziness/148788/6 "2018-10-30T14:29:38Z")

</div>

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