# Match queries and ASCII folding

**URL:** <https://discuss.elastic.co/t/match-queries-and-ascii-folding/319544>\
**Category:** Elasticsearch\
**Created:** [November 22, 2022, 11:39am UTC](https://discuss.elastic.co/t/match-queries-and-ascii-folding/319544 "2022-11-22T11:39:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![babolivier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babolivier/32/113645_2.png) [@babolivier](https://discuss.elastic.co/u/babolivier)\
**Post date:** [November 22, 2022, 11:39am UTC](https://discuss.elastic.co/t/match-queries-and-ascii-folding/319544/1 "2022-11-22T11:39:41Z")

</div>

Hi all,

I have an index that was created with the following configuration:

```json
{
  "settings": {
    "analysis": {
      "analyzer": {
        "std_asciifolding": {
          "tokenizer": "standard",
          "filter": ["std_asciifold_preserve", "lowercase"]
        }
      },
      "filter": {
        "std_asciifold_preserve": {
          "type": "asciifolding",
          "preserve_original": true
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "display_name": {
        "type": "text",
        "analyzer": "std_asciifolding"
      }
    }
  }
}

```

The idea is that the field `display_name` is searchable in a case- and diacritics-insensitive, to facilitate searching through non-English names.

One of the documents in this index looks like this:

```json
{
    "user_id": "XXXXXXX",
    "display_name": "Gáo foo",
    "avatar_url": null
}

```

Where the character `á` is a lowercase `a` followed by a `U+0301` (Combining Acute Accent).

When I try searching for this user in my index, the following query pulls up the document:

```json
{
    "query": {
        "match_phrase_prefix": {
            "display_name": {
                "query": "Ga"
            }
        }
    }
}

```

However, the following query does not:

```json
{
    "query": {
        "match_phrase_prefix": {
            "display_name": {
                "query": "Gao"
            }
        }
    }
}

```

This leads to confusing results where at first it looks like I can search for my user without the combining acute accent, but as I finish typing their display name it's suddenly not there anymore.

Am I missing something here?

---

<div class="post-metadata">

**Author:** ![babolivier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babolivier/32/113645_2.png) [@babolivier](https://discuss.elastic.co/u/babolivier)\
**Post date:** [November 22, 2022, 11:44am UTC](https://discuss.elastic.co/t/match-queries-and-ascii-folding/319544/2 "2022-11-22T11:44:25Z")

</div>

It's worth noting that the filter seems to be working as expected for other results, e.g. if I have the following document in my index:

```json
{
    "user_id": "XXXXXXX",
    "display_name": "Léonard foo",
    "avatar_url": null
}

```

Then the following search query returns my result:

```json
{
    "query": {
        "match_phrase_prefix": {
            "display_name": {
                "query": "Leo"
            }
        }
    }
}

```

---

<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 20, 2022, 11:44am UTC](https://discuss.elastic.co/t/match-queries-and-ascii-folding/319544/3 "2022-12-20T11:44:38Z")

</div>

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