Andy Bajka
Andy Bajka

Reputation: 169

ElasticSearch Mapping Charfilter

My objective is to be able to search for words with parenthesis around them, for example:

(Andy)

From what I can tell if I do a Mapping Charfilter and change the parenthesis to underscores this will accomplish what I'm after.

    "index" : {
        "analysis" : {
            "char_filter" : {
                "my_mapping" : {
                    "type" : "mapping",
                    "mappings" : ["( => _", ") => _"]
                }
            },
            "analyzer" : {
                "custom_with_char_filter" : {
                    "tokenizer" : "standard",
                    "char_filter" : ["my_mapping"]
                },
            }
        }
    }
}';

When I run the above I get the following error:

{"error":"ElasticSearchParseException[failed to parse source for create index]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@70de7f1b; line: 15, column: 14]]; ","status":400}

Upvotes: 2

Views: 2636

Answers (1)

imotov
imotov

Reputation: 30163

Carefully reread the error message. It has all the information you need to figure this one out. Basically, you have an extra comma on line 14, so the parser is expecting it to be followed by a name, instead it gets '}' on the line 15, column 14.

Upvotes: 4

Related Questions