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
}
Types are deprecated in APIs in 7.0, with breaking changes to the index creation, put mapping, get mapping, put template, get template and get field mappings APIs.
The crucial difference between them is that Elasticsearch will analyze the Text before it's stored into the Inverted Index while it won't analyze Keyword type. Analyzed or not analyzed will affect how it will behave when getting queried.
Basically, a type in Elasticsearch represented a class of similar documents and had a name such as customer or item . Lucene has no concept of document data types, so Elasticsearch would store the type name of each document in a metadata field of a document called _type.
Keyword fields in Elasticsearch are used to index and search for text values. They are also used to store metadata about the documents they are associated with.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With