Can't deal with accents in Elasticsearch indexing and search

Viewed 1681

I have an issue with elasticsearch and the way the data are indexed/retrieved. I don't understand what happens.

This is the mapping I use (sorry, it's yaml format) : The idea is simple, in theory... I have a string analyzer with lowercase and asciifolding filters. I don't want to care about case or accents, and I would like to use this analyzer to index and search.

settings:
    index:
        analysis:
            filter:
                autocomplete_filter:
                    type: edgeNGram
                    side: front
                    min_gram: 1
                    max_gram: 20
            analyzer:
                autocomplete:
                    type: custom
                    tokenizer: standard
                    filter: [lowercase, asciifolding, autocomplete_filter]
                string_analyzer:
                    type:        custom
                    tokenizer:   standard
                    filter:      [lowercase, asciifolding]
types:
    city:
        mappings:
            cityName:
                type: string
                analyzer: string_analyzer
                search_analyzer: string_analyzer
            location: {type: geo_point}

When I run this query :

{
    "query": {
        "prefix":{
            "cityName":"per"
        }
    }
    ,
    "size":20
}

I get some results like "Perpezat", "Pern", "Péreuil" which is the excepted result.

But if I run the following query :

{
    "query": {
        "prefix":{
            "cityName":"pér"
        }
    }
    ,
    "size":20
}

Then I get no result at all.

If you have any clue or help, I would be happy to know it. Thanks

2 Answers
Related