我在Elastic Search中使用父子文档。我可以使用_update API对主文档进行部分更新。但是,如果我在子文档上使用_update APi,则文档的内容将完全替换为脚本内容。出问题了...我不知道什么....
请参见下面的示例:
创建儿童文件
POST to /indexName/comment/c006?parent=b003
{
"authorId": "ps101",
"authorFullName": "Lieven",
"body": "Comment text comes here",
"isApproved": false
}
Run Code Online (Sandbox Code Playgroud)
获得孩子
GET to /indexName/comment/c006?parent=b003
{
_index: "indexName"
_type: "comment"
_id: "c006"
_version: 20
found: true
-_source: {
authorId: "ps101"
authorFullName: "Lieven"
body: "Comment text comes here."
isApproved: false
}
}
Run Code Online (Sandbox Code Playgroud)
部分更新
POST TO /indexName/comment/c006?parent=b003/_update
{
"script" : "ctx._source.isAcceptedAnswer=value",
"params" : {
"value" : true
}
}
Run Code Online (Sandbox Code Playgroud)
现在,重新与孩子
GET to /indexName/comment/c006?parent=b003
{
_index: "indexName"
_type: "comment"
_id: "c006"
_version: 21
found: true
-_source: {
script: "ctx._source.isAcceptedAnswer=value"
-params: {
value: true
}
}
}
Run Code Online (Sandbox Code Playgroud)
来源是完全错误的...
希望有人可以帮助马克
更改
POST TO /indexName/comment/c006?parent=b003/_update
Run Code Online (Sandbox Code Playgroud)
至
POST TO /indexName/comment/c006/_update?parent=b003
Run Code Online (Sandbox Code Playgroud)
?是查询字符串的开头,而结尾。
归档时间: |
|
查看次数: |
2337 次 |
最近记录: |