且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使弹性搜索将时间戳记字段添加到所有索引中的每个文档?

更新时间:2022-02-12 22:42:06

在创建索引时提供它。

$curl -XPOST localhost:9200/test -d '{
"settings" : {
    "number_of_shards" : 1
},
"mappings" : {
    "_default_":{
        "_timestamp" : {
            "enabled" : true,
            "store" : true
        }
    }
  }
}'

然后会自动创建一个 _timestamp 为您放在索引中的所有内容。
然后在请求_timestamp字段后索引一些东西,它将被返回。

That will then automatically create a _timestamp for all stuff that you put in the index. Then after indexing something when requesting the _timestamp field it will be returned.