我创建了摄取管道,并添加了时间戳:
PUT _ingest/pipeline/my_timestamp_pipeline
{
"description": "Adds a field to a document with the time of ingestion",
"processors": [
{
"set": {
"field": "ingest_timestamp",
"value": "{{_ingest.timestamp}}"
}
}
]
}
上面的流水线将一个字段ingest_timestamp添加到每个具有当前时间戳值的文档中。
PUT my_index/_doc/1
{
"foo": "bar"
}
如果我们现在检索这个文档,我们可以看到一个字段ingest_timestamp被添加到其中:
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"foo" : "bar",
"ingest_timestamp" : "2018-12-12T12:04:09.921Z"
}
}
如何将管道附加到当前索引?
2条答案
按热度按时间xlpyo6sf1#
有两种方法可以用您添加的字段更新所有文档
a)重新索引到备份索引,b)删除原始索引,c)从备份重新索引到命名为前一个的新索引。
1.在你的索引中有一点假。更棘手的是,你可以试试这样的东西。
curl -XPOST localhost:9200/my_index/_update_by_query?pretty -d'{“script”:{“inline”:“ctx._source.foo = ctx._source.foo”},“query”:{“match_all”:联系我们
你可以从这个例子中看到,这个想法是用相同的值更新值。你可以试试你自己的领域
gmol16392#
我想,在第一种方式中,我应该在目标索引中添加管道?例如
虽然我检查了GET
new_index/_doc/1
没有显示新的时间戳字段。仅仅更新索引设置还不够吗?