# Fuzzy in searchs with asciifolding

**URL:** <https://discuss.elastic.co/t/fuzzy-in-searchs-with-asciifolding/155586>\
**Category:** Elasticsearch\
**Created:** [November 6, 2018, 5:43pm UTC](https://discuss.elastic.co/t/fuzzy-in-searchs-with-asciifolding/155586 "2018-11-06T17:43:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Victor\_da\_Silva](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@Jose\_Victor\_da\_Silva](https://discuss.elastic.co/u/Jose_Victor_da_Silva)\
**Post date:** [November 6, 2018, 5:43pm UTC](https://discuss.elastic.co/t/fuzzy-in-searchs-with-asciifolding/155586/1 "2018-11-06T17:43:31Z")

</div>

Good afternoon,  
I'm trying to use a "custom analyzer" called test\_fuzzy in a fuzzy search, but it does not work when I insert the "preserve\_original" option to "true" in the "asciifolding" filter.

When I create a "custom\_analyzer" setting the "preserve\_original" as false, then the search returns results correctly.

I saw in elastic documentation that fuzziness would be applied in each term (after analysis), Does anyone know the elastic reason not being able to find my documents even though there are more tokens (more options) using "preserve\_original" as true?

The following is when preserve\_original is active (test\_fuzzy):

```
{
  "tokens": [
    {
      "token": "produto",
      "start_offset": 0,
      "end_offset": 7,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "varzacao",
      "start_offset": 8,
      "end_offset": 16,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "varzação",
      "start_offset": 8,
      "end_offset": 16,
      "type": "<ALPHANUM>",
      "position": 1
    }
  ]
}

```

The following is when preserve\_original is disabled (test\_fuzzy):

```
{
  "tokens": [
    {
      "token": "produto",
      "start_offset": 0,
      "end_offset": 7,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "varzacao",
      "start_offset": 8,
      "end_offset": 16,
      "type": "<ALPHANUM>",
      "position": 1
    }
  ]
}

```

Here is the query executed:

```
[
                'match' => [
                    'name.fuzzy' => [
                        'query' => 'produto varzação',
                        'operator' => 'and',
                        'boost' => 2,
                        'zero_terms_query' => 'all',
                        'fuzziness' => 'auto' ]
                ]
            ]

```

Follow the mapping :

```
'name' =>
                    [
                        'type' => 'text',
                        'analyzer' => 'standard',
                        'fields' => [
                            'norm' => [
                                'type' => 'keyword',
                                'normalizer' => 'keyword_text'
                            ],
                            'stemmed' => [
                                'type' => 'text',
                                'analyzer' => 'stemmed'
                            ],
                            'fuzzy' => [
                                'type' => 'text',
                                'analyzer' => 'test_fuzzy'
                            ]
                        ],
                    ],

```

Follow the parser and filter:

```
 'test_fuzzy' => [
        'tokenizer' => 'standard',
        'filter' => [
            'lowercase',
            'custom_asciifolding',
        ]
 ],

```

* * *

```
 'filter' => [
        'custom_asciifolding' => [
            'type' => 'asciifolding',
            'preserve_original' => 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:** [December 4, 2018, 5:43pm UTC](https://discuss.elastic.co/t/fuzzy-in-searchs-with-asciifolding/155586/2 "2018-12-04T17:43:36Z")

</div>

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