# Trying to get a fuzziness example to work

**URL:** https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402
**Category:** Elasticsearch
**Created:** [February 16, 2022, 5:59pm UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402 "2022-02-16T17:59:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![MrFantastic2022](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MrFantastic2022](https://discuss.elastic.co/u/MrFantastic2022)
#### Post date: [February 16, 2022, 5:59pm UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402/1 "2022-02-16T17:59:53Z")

</div>

Hi,  
I'm trying to follow the example for fuzziness given [here](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-query-string-query.html#_fuzziness) against the sample bank index. Here's the query:

```auto
GET /bank/_search?q=employer:Qu~

```

It returns nothing, but I expect to get 2 records, at least, from what I see from the data on my screen.

Thanks in advance to all who respond.

---

<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: [February 17, 2022, 9:35am UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402/2 "2022-02-17T09:35:09Z")

</div>

This is hard to say without looking at the sample data, but take this as an example.

```auto
PUT test/_doc/1
{
  "firstname" :"Alexander"
}

GET test/_search
{
  "query": {
    "query_string": {
      "default_field": "firstname",
      "query": "Alexandel~"
    }
  }
}

# no results
GET test/_search
{
  "query": {
    "query_string": {
      "default_field": "firstname",
      "query": "Alex~"
    }
  }
}

# same in URL
GET test/_search?q=firstname:Alexandel~

GET test/_search?q=firstname:Alex~

```

Keep in mind that fuzzy search is not a prefix search but it is about edit distance.

hope this helps.

---

<div class="post-metadata">

### Author: ![MrFantastic2022](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MrFantastic2022](https://discuss.elastic.co/u/MrFantastic2022)
#### Post date: [February 17, 2022, 4:58pm UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402/3 "2022-02-17T16:58:09Z")

</div>

Hi, Alexander - thanks for the information. I tried your example in my Kibana console and it worked exactly as you described. However, when I tried to apply it to data in my index, I never get any hits. I basically copied your REST calls and changed the field to be one in my mapping; data in that field has text like "line" so I put in "lint~" and that did not work. There are lots of other examples in the documentation which don't work for some reason in my environment, most importantly the filter code. But that is a separate issue that I posted elsewhere in this forum. Thanks for your help!

---

<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: [February 21, 2022, 1:22pm UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402/4 "2022-02-21T13:22:55Z")

</div>

Hey,

that is entirely possible due to a different mapping. Can you share a **fully reproducible** example that includes index and mapping creation, so we can take a look?

Thanks!

--Alex

---

<div class="post-metadata">

### Author: ![MrFantastic2022](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MrFantastic2022](https://discuss.elastic.co/u/MrFantastic2022)
#### Post date: [February 21, 2022, 2:40pm UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402/5 "2022-02-21T14:40:33Z")

</div>

Hi, Alex -

Unfortunately, due to the nature of my work, that is impossible. My interest in this is purely academic; I'm new to ES and was tasked with an ES effort, so I am trying to learn as much as I can about what's possible with the different language features so that I can address customer needs more effectively, should needs beyond the current scope of our capabilities arise. Thank you for your help nonetheless.

---

<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: [March 21, 2022, 2:41pm UTC](https://discuss.elastic.co/t/trying-to-get-a-fuzziness-example-to-work/297402/6 "2022-03-21T14:41:26Z")

</div>

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