我正在 ES 1.5.2 中工作。我有一个包含文档的索引,其中存储了时间戳值。我想向其中添加一个常规字段,该字段将采用该文档的 _timestamp 字段的值。我怎样才能做到这一点?我可以
PUT twitter/_mapping/new_timestamp
{
"properties": {
"name": {
"type": "float"
}
}
}
创建一个常规字段,但如何将所有 _timestamp 值复制到其中?
在 ES 1.5.2 中,您可以使用通过查询插件更新为了重新索引您的文档并复制_timestamp
字段变为常规字段。
使用以下命令安装插件后:
bin/plugin -url http://oss.sonatype.org/content/repositories/releases/com/yakaz/elasticsearch/plugins/elasticsearch-action-updatebyquery/1.0.0/elasticsearch-action-updatebyquery-1.0.0.zip install elasticsearch-action-updatebyquery
并确保动态脚本已启用在你的elasticsearch.yml
配置文件,您将能够运行以下命令
POST /twitter/_update_by_query
{
"script": {
"inline": "ctx._source.new_timestamp = ctx._timestamp”
},
"query": {
"match_all": {}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)