1.先增加后赋值
PUT item_sku/_mapping
{
"properties": {
"shop-bag": {
"type": "integer"
}
}
}
POST item_sku/_update_by_query
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "shop_bag"
}
}
]
}
},
"script": {
"source": "ctx._source['shop_bag'] = 0"
}
}
2.增加时赋值
PUT 索引名/_mapping
{
"properties": {
"pushTime": {
"type": "long"
}
}
}
POST 索引名/_update_by_query
{
"script": {
"lang": "painless",
"source": "if (ctx._source.pushTime== null) {ctx._source.pushTime= 1332466576}"
}
}