# Terms with fuzzy operator don't use mapping analyzer, but always standard analyzer

**URL:** <https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593>\
**Category:** Elasticsearch\
**Created:** [December 9, 2016, 5:39pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593 "2016-12-09T17:39:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [December 9, 2016, 5:39pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/1 "2016-12-09T17:39:36Z")

</div>

Hi,

fuzzy operator is a really powerful feature for full-text search.

But I have a problem :  
When I do a fuzzy search (ex: `accenTTué~1`), I see that analyzer used is standard analyzer (which has only a lowercase filter).

I mean : if in my mapping, I define a custom analyzer with asciifolding filter, I can clearly see that it is not used for my search terms.  
However, I see that lowercase filter is used.  
That's why it seems that, by default, elasticsearch uses always standard analyzer to analyze search terms with fuzzy operator.

So my question is : is there a way to say elasticsearch to use the mapping analyzer when fuzzy operator is used ?  
It can be a parameter in the query or a settings/mapping configuration in the index.

Thanks in advance for your help,  
Fabien

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 9, 2016, 5:51pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/2 "2016-12-09T17:51:33Z")

</div>

> [@fbaligand](#):
>
> When I do a fuzzy search (ex: accenTTué~1), I see that analyzer used is standard analyzer (which has only a lowercase filter).

Can you share the entire query you're using? Are you using `query_string` or  
`simple_query_string`?

> I mean : if in my mapping, I define a custom analyzer with asciifolding filter, I can clearly see that it is not used for my search terms.However, I see that lowercase filter is used.That's why it seems that, by default, elasticsearch uses always standard analyzer to analyze search terms with fuzzy operator.

If you are doing a `query_string` query with no field specified, then by default  
you're searching the `_all` field, which may not have the analyzer you suspect.

> So my question is : is there a way to say elasticsearch to use the mapping analyzer when fuzzy operator is used ?It can be a parameter in the query or a settings/mapping configuration in the index.

A better way to do this would be to use a `match` query with "fuzziness"

> **[Match Query | Elasticsearch Guide \[5.1\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-match-query.html#query-dsl-match-query-fuzziness)**

Which should use the analyzer specific to whatever field you're searching.

If you can share more information about your documents and full query, I can try  
to reproduce.

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [December 10, 2016, 11:54am UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/3 "2016-12-10T11:54:18Z")

</div>

Hi @dakrone,

First, thank for your help !

Then, to answer your questions :

- I am using `query_string`, but I reproduce the problem also with `simple_query_string`
- I don't search in \_all but in a specific field which has a custom analyzer
- I tried with match query. Indeed, it works fine. Thanks for the advice
- However, my final query need is complex : multiple or/and conditions with parenthesis, search in different fields with different fuzziness levels (0,1,2) and different boosts. That's why I need for query\_string query.

So that you can reproduce the query, here's all the details.

Here's my index :

```
PUT search_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    }
  },
  "mappings": {
    "search_type": {
      "properties": {
        "text": {
          "type": "text",
          "analyzer": "my_analyzer"
        }
      }
    }
  }
}

```

Here's my document which should be found :

```
PUT search_index/search_type/1
{
  "text": "accentue"
}

```

And here's my query with fuzziness :

```
GET search_index/_search
{
  "query": {
    "query_string": {
      "query": "text:accenTTué~1"
    }
  }
}

```

Thanks in advance for your help !

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [December 13, 2016, 8:58pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/4 "2016-12-13T20:58:42Z")

</div>

Hi @dakrone  
Have you test this configuration ?  
Should I open an issue in elasticsearch github about that ?

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 13, 2016, 9:36pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/5 "2016-12-13T21:36:04Z")

</div>

> [@fbaligand](#):
>
> Have you test this configuration ?

Hi @fbaligand sorry this has taken some time. I have been researching this. It looks like this is a known issue, if you check out [Remove fuzzy query · Issue #15760 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/15760), specifically, Option 2 mentions analyzing fuzzy terms.

I believe that in your case the fuzzy term is not being analyzed at all, which is why it doesn't match.

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [December 13, 2016, 10:25pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/6 "2016-12-13T22:25:43Z")

</div>

Hi @dakrone,

This is not as simple as not analyzed.  
I mean : if I search `text:accenTTue~1` (without prominent character), my document is found.  
So it means that, at least, lowercase filter is applied.

Anyway, I'm very surprised this does not work, as for wildcards, you can activate analyze on wildcard terms using `"analyze_wildcard": true` and it works.  
And to me, this is really more complicated/special to analyze wildcard terms, than fuzzy terms.

So, your final answer is that, presently, this doesn't work and there is no option to activate analyze on fuzzy terms (like `"analyze_fuzzy": true`) ?

---

<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:** [January 10, 2017, 10:26pm UTC](https://discuss.elastic.co/t/terms-with-fuzzy-operator-dont-use-mapping-analyzer-but-always-standard-analyzer/68593/7 "2017-01-10T22:26:20Z")

</div>

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