Elasticsearch version 7 cannot be changed from type [keyword] to [text]

30.1k Views Asked by At

I am a newbie of elasticsearch. I create a mapping using such code:

PUT /my-demo1
{
  "mappings": {
    "properties": {
      "dsu_sn": {
        "type": "keyword"
      },
      "iot_id": {
        "type": "keyword"
      },
      "test_suite_id": {
        "type": "text"
      },
      "error_code": {
        "type": "long"
      }
    }
  }
}

ES responses mapper [iot_id] cannot be changed from type [keyword] to [text] when I index a document using such code:

POST /my-demo1/1
{
  "dsu_sn": "ssl123321",
  "iot_id": "550068573720395776",
  "test_suite_id": "com.example.test.wifi",
  "error_code": 2
}
2

There are 2 best solutions below

2
On BEST ANSWER

You need to add _doc in URL while posting a document to Elasticsearch, change the URL to POST /my-demo1/_doc/1

Refer removal of types for more info.

1
On

I got this error becuase of a missing index alias. I deleted the index, set up the new mapping and settings, but forgot to set the alias. Then I tried to post documents to the alias...