Simple "Mappings" section throws error


(Jason Smith) #1

Hello folks

I am typing a structure for an index. I am getting
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [animals] as the final mapping would have more than 1 type: [carnivore, herbivore]"
}

        PUT /animals/_mapping/carnivore
        {
                    "properties": {
                    "name": 
                     {
                                     "type": "text",
                                     "analyzer": "standard"
                    }
                  }
         }
        PUT /animals/_mapping/herbivore
        {
                 "properties": {
                             "name": 
                             {
                                           "type": "text",
                                          "analyzer": "standard"
                              }
                   }
        }

(Jon Budzenski) #2

As of Elasticsearch 6.0 indices with more than one type are nor allowed. Long term the _type field is going away. The error is saying we have one type, carnivore, and now we're trying to add a new type called herbivore. Are you following this from a guide? Maybe we can get it updated.

There's several options for resolving.

Add a type field with each document, that becomes herbivore or carnivore:

PUT /animals/_mapping/doc
{
  "properties": {
    "name": {
      "type": "text",
      "analyzer": "standard"
    },
    "type": {
       "type": "keyword"
    }
  }
}

Alternatively, separate indices for each type:

PUT /herbivore/_mapping/doc
{
  "properties": {
    "name": {
      "type": "text",
      "analyzer": "standard"
    }
  }
}

PUT /carnivore/_mapping/doc
{
  "properties": {
    "name": {
      "type": "text",
      "analyzer": "standard"
    }
  }
}

(Jason Smith) #3

Ok got it. For one "index" (equivalent to "database" in RDBMS world) we can have only one "type".
This change is from Elasticsearch 6.0

No I didn't try this from Elastic guide. I tried it from a sample from some other site. Looks like that sample is from older version of Elasticsearch version.

Thank You very much


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.