gpt4 book ai didi

elasticsearch - Elasticsearch 部分更新

转载 作者:行者123 更新时间:2023-12-03 01:58:40 24 4
gpt4 key购买 nike

我想做如下的部分更新。添加一些新字段,例如Bytes_In和Bytes_Out。并且还运行脚本来更新使用脚本从其他字段派生的字段。

脚本session-duration-script.groovy在/ config / scripts路径下。

ctx._source.duration= (new Date().parse("yyyy-MM-dd HH:mm:ss.SSS",ctx._source.sessionTerminationDateTime.replace("T", " ").substring(0,23)).getTime() - new Date().parse("yyyy-MM-dd HH:mm:ss.SSS",ctx._source.eventConversionDateTime.replace("T", " ").substring(0,23)).getTime())


access/access-event-logs/session-summary/0a30fd59karabip1new.lab.fp.f5net.com/_update
{
"doc" : {
"active" : false,
"Bytes_In": "100",
"Bytes_Out": "100",
"sessionTerminationDateTime": "2015-10-30T02:50:39.237Z"
},
"script_fields": {
"my_field": {
"script_file": "session-duration-script"
}
}
}

当我运行上述更新查询时,出现此错误
{
"code": 400,
"message": "status:400, body:{\"error\":{\"root_cause\":[{\"type\":\"action_request_validation_exception\",\"reason\":\"Validation Failed: 1: can't provide both script and doc;\"}],\"type\":\"action_request_validation_exception\",\"reason\":\"Validation Failed: 1: can't provide both script and doc;\"},\"status\":400}",
"originalRequestBody": "{\"error\":{\"root_cause\":[{\"type\":\"action_request_validation_exception\",\"reason\":\"Validation Failed: 1: can't provide both script and doc;\"}],\"type\":\"action_request_validation_exception\",\"reason\":\"Validation Failed: 1: can't provide both script and doc;\"},\"status\":400}",
"referer": "172.17.86.67",
"restOperationId": 6555035,
"kind": ":resterrorresponse"
}

请让我知道有实现这种更新的方法。

最佳答案

由于错误状态,您不能同时使用docscript。我的建议是修改脚本,以添加所需的字段,并使用params映射传递这些字段的值。

关于elasticsearch - Elasticsearch 部分更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34666720/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com