Reputation: 716
I have an existing index in elasticsearch (version : 5.1.1) which has some documents index in it. A mapping in the index (say hardware) has a a field as follows :
"biosSerialNumber" :{
"type":"keyword"
}
I want to add a field to it with analyzer as follows : "biosSerialNumber" :{ "type":"keyword", "fields":{ "suffix":{ "type":"text", "analyzer":"abc_analyzer" } } }
"abc_analyzer" analyzer already exists in the index settings. Is it allowed? I have tried doing this using PUT commands which I have used to add new fields in the index. But it does not seem to work.
Getting this error :
{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "Mapping definition for [fields] has unsupported parameters: [analyzer : suffix_match_analyzer]" } ], "type": "mapper_parsing_exception", "reason": "Mapping definition for [fields] has unsupported parameters: [analyzer : suffix_match_analyzer]" }, "status": 400 }
Upvotes: 0
Views: 520
Reputation: 716
As mentioned in the comment, the error was because I was trying to add an analyzer to a 'keyword' field, which is not allowed (for the obvious reason that keyword type is not analyzed)!. This was a sample try-out.
Also, now after running a PUT request to :
<elshost>/<index-name>/_mapping/<doc-type>
with the request body :
{
"properties":{
"asset":{
"properties" :{
"biosSerialNumber":{
"type":"keyword",
"fields":{
"suffix":{
"type":"text",
"analyzer":"abc_analyzer"
}
}
}
}
}
}
}
worked.
I understand, for this to take effect on the existing data in the field, documents need to be re-indexed.
Upvotes: 0