0

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 }

3
  • 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. Commented Sep 30, 2019 at 11:03
  • Can you show the PUT command you have sent? Commented Sep 30, 2019 at 11:14
  • yes, just posted in an answer. Commented Sep 30, 2019 at 11:17

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Glad you figured it out. You can simply call POST <elshost>/<index-name>/_update_by_query in order to make sure all documents pick up the new field. NO need tou reindex from an external data source.
ohhk, that's awesome and very useful. Thanks.
Hi @Val, I have asked a new question w.r.t _update_by_query. Can you check? link:stackoverflow.com/questions/58510637/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.