This is my index settings: PUT my_index
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"char_filter": [
"my_char_filter"
]
}
},
"char_filter": {
"my_char_filter": {
"type": "pattern_replace",
"pattern": "^([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)",
"replacement": "$1$2"
}
}
}
}
}
I'm trying to analyze this query:
POST my_index/_analyze
{"analyzer":"my_analyzer","text":"elastic-search"}
POST my_index/_analyze
{"analyzer":"my_analyzer","text":"-search"}
Case 1 works fine but for case 2, i get the token 'search' which is not what i want. I want it to skip it if i don't provide text preceding the hyphen. What am i doing wrong?