I want to apply custom analyzer to all fields in an existing mapping to enable search with special characters.
I created custom ngram analyzer and a dynamic template to apply custom_analyzer on all text fields to do so.
Search for simple text without any special character works fine But when I search for any special character within _category field , it is returning 0 results.
To test for custom_analyzer I created a new field(email) in the mapping with analyzer and search of special characters on this email field giving me expected results.
I also created a new field(phone No) without analyzer to check if dynamic_template apply my custom_analyzer to that phone field , But I am not getting expected results.
Please suggest how dynamic_templates work? If we can apply dynamic_templates to existing mappings or if to a new field in existing mapping?
http://localhost:9200/audit/_mapping
"audit": {
"mappings": {
"logs": {
"dynamic_templates": [
{
"ngram_string_analyzers": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"analyzer": "custom_analyzer",
"type": "text"
}
}
}
],
"properties": {
"_category": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"_createdOn": {
"type": "date"
}
}
}
}
}
"audit": {
"settings": {
"index": {
"number_of_shards": "5",
"provided_name": "audit",
"creation_date": "1556778930604",
"analysis": {
"analyzer": {
"custom_analyzer": {
"type": "custom",
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "ngram",
"min_gram": "1",
"max_gram": "10"
}
}
},
"number_of_replicas": "1",
"version": {
"created": "6040099"
}
}
}
}
}