更新操作 ../1/_update 更新如果和原数据相同,则不需要更新版本
put 或不带update post 都会更新所有数据
elasticsearch 操作数组
PUT /test_index
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
}
}
post /test1/_update/1
{
"script": {
"source": "if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }",
"lang": "painless",
"params": {
"tag": "tag2"
}
}
}
POST test/_update/1
{
"script": {
"source": "if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }",
"lang": "painless",
"params": {
"tag": "blue"
}
}
}
get /test1/_search
put /associated_word
{
"settings": {
"number_of_shards": 36,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"onsite_search_word_key": {
"type": "keyword"
},
"onsite_search_word": {
"type": "keyword"
},
"score": {
"type": "float"
}
}
}
}
REST APIs > Document APIs > Update Update API | Elasticsearch Guide [7.15] | Elastic
本文介绍了Elasticsearch中如何使用PUT和POST更新文档,特别是更新数组字段的示例。通过_painless脚本,展示了删除数组元素的方法。同时,展示了创建索引与设置映射的步骤,并提供了RESTful API的使用示例。
3387

被折叠的 条评论
为什么被折叠?



