Jiří Chmiel
Jiří Chmiel

Reputation: 876

How to filter multiple characters in Elasticsearch

Is there a way how to filter multiple characters during analyzing in ElastisSearch? We would like to setup it so if user searches 'botled' then he get the documents that include 'bottled' or 'botttled', etc., i.e no matter double, tripple letters.

I have looking for solution in token filters https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenfilters.html, but it seems that none of them matches our requirements.

Upvotes: 1

Views: 299

Answers (1)

Kaushik J
Kaushik J

Reputation: 1062

by default elasticsearch text field is tokenized based on whitespace, i.e. only words are indexed and are searchable.


would regex search work for you?
GET /_search
{
    "query": {
        "regexp": {
            "user": {
                "value": "b+o+t+t+l+e+d+"
            }
        }
    }
}

b+ --> one or more occurrence of b

Upvotes: 1

Related Questions