Elasticsearch 1.x添加时间戳的字段副本 [英] Elasticsearch 1.x add field copy of 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
POST / twitter / _update_by_query
{
script:{
inline:ctx._source.new_timestamp = ctx._timestamp
},
query:{
match_all:{}
}
}
I am working in ES 1.5.2. I have an index with documents, with stored timestamp values. I want to add a regular field to it, which will assume the value of the _timestamp field for that document. How can I do this? I could do
PUT twitter/_mapping/new_timestamp
{
"properties": {
"name": {
"type": "float"
}
}
}
to create a regular field, but how can I copy over all the _timestamp values to it?
In ES 1.5.2, you can use the update by query plugin in order to reindex your documents and copy the _timestamp
field to a regular field.
After installing the plugin with the following command:
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
And making sure that dynamic scripting is enabled in your elasticsearch.yml
configuration file, you'll be able to run the following command
POST /twitter/_update_by_query
{
"script": {
"inline": "ctx._source.new_timestamp = ctx._timestamp"
},
"query": {
"match_all": {}
}
}
这篇关于Elasticsearch 1.x添加时间戳的字段副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!