I'm looking to convert the data type of a field from long
to text
. I have a field with the mapping
"shopId": {
"type": "long"
}
I first iserted some documents like:
{"shopId": "25"},{"shopId": "26"},{"shopId": "27"}
I then added another field with the type text
:
{
"anotherShopId":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
So now my mapping/schema look like this:
{
"sanchitindex":{
"aliases":{
},
"mappings":{
"properties":{
"anotherShopId":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"shopId":{
"type":"long"
}
}
},
"settings":{
"index":{
"creation_date":"1612778764965",
"number_of_shards":"1",
"number_of_replicas":"1",
"uuid":"S0iqrEIKS96XMnRgXkGsiQ",
"version":{
"created":"7030199"
},
"provided_name":"sanchitindex"
}
}
}
}
I'm trying to migrate the shopId
values to anotherShopId
using the Reindex API.
POST http://localhost:9200/sanchitindex/_reindex
{
"source": {
"index": "shopId"
},
"dest": {
"index": "anotherShopId"
},
"script": {
"inline": "ctx._source.shopId = String.valueOf(ctx._source.shopId)"
}
}
But I was not able to do so as I'm getting the following response:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [sanchitindex] as the final mapping would have more than 1 type: [_doc, _reindex]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [sanchitindex] as the final mapping would have more than 1 type: [_doc, _reindex]"
},
"status": 400
}
Version: 7.3.1
Is there any other way to migrate the data from long
to text
?