gpt4 book ai didi

elasticsearch - 使用现有列值更新Elastic Search的所有文档

转载 作者:行者123 更新时间:2023-12-03 00:09:45 24 4
gpt4 key购买 nike

我在 flex 搜索中有一个字段“published_date”,并且那里有完整的日期,例如 yyyy-MM-dd'T'HH:mm:ss

我想为日期再创建3列,我必须使用现有的published_date 来更新新的3列。

是否有任何内置的api在e.s.中进行此类工作?我正在使用elasticsearch 5。

最佳答案

您可以使用update-by-query API来执行此操作。它将简单地归结为运行以下命令:

POST your_index/_update_by_query
{
"script": {
"inline": "ctx._source.year = ctx._source.published_date.date.getYear(); ctx._source.month = ctx._source.published_date.date.getMonthOfYear(); ctx._source.day = ctx._source.published_date.date.getDayOfYear(); ",
"lang": "groovy"
},
"query": {
"match_all": {}
}
}

还要注意,您需要 enable dynamic scripting才能使它起作用。

关于elasticsearch - 使用现有列值更新Elastic Search的所有文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41867756/

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