POST _reindex
{
"source": {
"index": "test"
},
"dest": {
"index": "test2"
}
}
相当于旧表:test
新表:test2
================================================
POST _reindex
{
"source": {
"index": "test"
},
"dest": {
"index": "test2"
},
"script": {
"source": "ctx._source.tag = ctx._source.remove(\"flag\")"
}
}
新表旧表和上面一致,不同之处在于是旧表中的字段flag被新表tag替换了,数据结构不变。
因为ES不支持改变结构,只能替换表的方式添加修改,目前还没细入研究,希望可以得到不懂得意见。
================================================
新知
修改索引的字段值
POST /索引名称/_update_by_query
{
"query": {
"bool": {
"must": [
{
"match": {
"status": "1"
}
}
]
}
},
"script": {
"inline": "ctx._source['major'] = 'net';ctx._source['com_name'] = 'lisi'"
}
}
================================================
条件删除
POST lhzz_organization/_delete_by_query
{
"query": {
"range": {
"create_time.keyword": {
"gte": "2023-04-22 00:00:00",
"lte": "2025-04-22 00:00:00"
}
}
}
}