field mappings cannot be changed
--> except for some parameters like ignore_above, etc.
mapping is immutable as data could already been indexed
changing type requires whole data structure to be rebuild
docs need to be reindexed for type change
retrieves docs from source index and indexes it to the destination index
PUT /reviews_new
{
"mappings" : {
"properties" : {
"author" : {
"properties" : {
"email" : {
"type" : "keyword",
"ignore_above" : 256
},
"first_name" : {
"type" : "text"
},
"last_name" : {
"type" : "text"
}
}
},
"content" : {
"type" : "text"
},
"created_at" : {
"type" : "date"
},
"product_id" : {
"type" : "keyword" // changed from "integer"
},
"rating" : {
"type" : "float"
}
}
}
}
POST /_reindex
{
"source" : {
"index" : "reviews"
},
"dest" : {
"index" : reviews_new
}
}
scripts can be supplied on reindex
POST /_reindex
{
"source" : {
"index" : "reviews"
},
"dest" : {
"index" : reviews_new
},
"script" : {
"source" : """
if (ctx._source.product_id != null) {
ctx._source.product_id = ctx._source.product_id.toString();
}
"""
}
}
PUT /reviews/_mapping
{
"properties" : {
"comment" : {
"type" : "alias",
"path" : "content"
}
}
}