0
votes

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 }

1
Btw, cause for the error mentioned above is that, 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. But the first question still remains.User3518958
Can you show the PUT command you have sent?Val
yes, just posted in an answer.User3518958

1 Answers

0
votes

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.