当前位置: 首页 > elasticsearch, 搜索 > 正文

翻译 elasticsearch _timestamp

关键字:
1 星2 星3 星4 星5 星 (1 次投票, 评分: 5.00, 总分: 5)
Loading ... Loading ...
baidu_share

原文地址:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-timestamp-field.html

The _timestamp field allows to automatically index the timestamp of a document. It can be provided externally via the index request or in the _source. If it is not provided externally it will be automatically set to the date the document was processed by the indexing chain.

_timestamp字段允许自动索引的文档的时间戳。它可以通过外部提供的索引请求提供,或者在_source里面提供。如果它不能通过外部提供,它将自动设置当前时间给处理的文档。

enabled 启用
By default it is disabled, in order to enable it, the following mapping should be defined:
默认,它是禁用的。为了启用它,下面的映射应该如下定义:

{
    "tweet" : {
        "_timestamp" : { "enabled" : true }
    }
}

store/index 存储/索引
By default the _timestamp field has store set to no and index set to not_analyzed. It can be queried as a standard date field.

默认情况,_timestamp字段已经存储,不索引,设置不用分词(not_analyzed)。它需要标准时间字段。

path路径

The _timestamp value can be provided as an external value when indexing. But, it can also be automatically extracted from the document to index based on a path. For example, having the following mapping:

当索引时,_timestamp值可以提供一个外部值。但是,它仍然可以自动从文档中提取基于路径。例如,有下面映射:

{
    "tweet" : {
        "_timestamp" : {
            "enabled" : true,
            "path" : "post_date"
        }
    }
}

Will cause 2009-11-15T14:12:12 to be used as the timestamp value for:

用2009-11-15T14:12:12 时间作为时间戳值:

{
    "message" : "You know, for Search",
    "post_date" : "2009-11-15T14:12:12"
}

Note, using path without explicit timestamp value provided require an additional (though quite fast) parsing phase.
注意,使用路径没有明确的时间戳值,需要另外提供一个(虽然相当快)。

format格式化
You can define the date format used to parse the provided timestamp value. For example:

你可以定义时间格式去解析提供的时间戳值。例如:

{
    "tweet" : {
        "_timestamp" : {
            "enabled" : true,
            "path" : "post_date",
            "format" : "YYYY-MM-dd"
        }
    }
}

Note, the default format is dateOptionalTime. The timestamp value will first be parsed as a number and if it fails the format will be tried.

注意,默认的格式化是dateOptionalTime.时间戳值将被解析为一个数字。如果解析失败了,将会去尝试。

本文固定链接: http://www.chepoo.com/translate-elasticsearch-_timestamp.html | IT技术精华网

【上一篇】
【下一篇】

翻译 elasticsearch _timestamp:等您坐沙发呢!

发表评论