I just have problem with elasticsearch, I have some business requirement that need to search with special characters. For example, some of the query string might contain (space, @, &, ^, (), !) I have some similar use case below.
- foo&bar123 (an exact match)
- foo & bar123 (white space between word)
- foobar123 (No special chars)
- foobar 123 (No special chars with whitespace)
- foo bar 123 (No special chars with whitespace between word)
- FOO&BAR123 (Upper case)
All of them should match the same results, can anyone please give me some help about this? Note this right now I can search other string with no special characters perfectly
{
"settings": {
"number_of_shards": 1,
"analysis": {
"analyzer": {
"autocomplete": {
"tokenizer": "custom_tokenizer"
}
},
"tokenizer": {
"custom_tokenizer": {
"type": "ngram",
"min_gram": 2,
"max_gram": 30,
"token_chars": [
"letter",
"digit"
]
}
}
}
},
"mappings": {
"index": {
"properties": {
"some_field": {
"type": "text",
"analyzer": "autocomplete"
},
"some_field_2": {
"type": "text",
"analyzer": "autocomplete"
}
}
}
}
}