David Munsa
David Munsa

Reputation: 893

Elasticsearch illegal_argument_exception when insert new document

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
}

Upvotes: 1

Views: 3590

Answers (2)

David Munsa
David Munsa

Reputation: 893

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

Upvotes: 0

Amit
Amit

Reputation: 32386

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

Upvotes: 0

Related Questions