1

I am getting a illegal_argument_exception error on a new and empty index

iam new to elasticsearch so I am guessing I misuse the keyword feature I want to be able to aggregate the VisitorDeviceOs field

this is my mapping

{
   "mappings":{
      "properties":{
         "Id":{
            "type":"integer"
         },
         "VisitorDeviceOs":{
            "type":"keyword","null_value": "NULL"
         },
      }
   }
}

this is the PUT request to insert the new document

{
   "Id":18858,
   "VisitorDeviceOs":"Windows",
}

full error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "mapper [VisitorDeviceOs] cannot be changed from type [keyword] to [text]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "mapper [VisitorDeviceOs] cannot be changed from type [keyword] to [text]"
  },
  "status" : 400
}
3
  • did you create a fresh index with your mapping? Commented Nov 16, 2020 at 10:10
  • i deleted the old one and created new one (with the same name) Commented Nov 16, 2020 at 10:23
  • Did you delete the index or just the documents?? please refer to my answer for more details Commented Nov 16, 2020 at 10:25

2 Answers 2

0

Doesn't look like that you created a fresh index with provided mapping, and indexed the doc immediately(tried myself once again and it works fine).

This error comes when you try to update the data-type of field(in your case from keyword to text) which is not allowed.

Please refer update mapping of a field and whats allowed and not allowed for more details.

As mentioned updating the type in mapping is not allowed, refer full list of updatable values here

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

1 Comment

@DavidMunsa, which version you are using? and which command you used to delete the old index?
0

problem was that i forget the _create in the URL

it works now like this

PUT http://localhost:9200/index_name/_create/88879f32080f468b93fe23e3a73b1c86

thanks everyone

Comments

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.