1
votes

How can I ignore apostrophes both in the documents and query?

e.g.

Document:

{
  name: "Ch`iroki the Big Dud"
}

Query:

name match "Ch`irki"

While still getting the original text in the result and using other language analyzer.

I tried adding replace_pattern char_filter but it didn't work.

EDIT

This is the index settings:

{
    "settings": {
        "analysis": {
            "char_filter": {
                "replace_apostrophe": {
                    "type": "pattern_replace",
                    "pattern": "'",
                    "replacement": ""
                }
            }
        }
    }
}

This is the _analyze request:

{
    "char_filters": ["replace_apostrophe"],
    "text": "a'b'c"
}

This is the _analyze response:

{
    "char_filters": ["replace_apostrophe"],
    "text": "a'b'c"
}

Where am I wrong?

1
Can you show your index settings and mappings?Val

1 Answers

0
votes

char_filter should work, see https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-mapping-charfilter.html

Did you try analyze API to check how the input string is tokenized?