没有条目关闭时,弹性结果接近时间戳

时间:2018-11-26 12:21:11

标签: elasticsearch

我一直在使用以下请求来获取接近时间戳的条目,并且效果很好,直到我选择的日期超出了迄今为止的索引范围。例如。将来或在几周前我已停止索引的日志中。

# Get log close to date
GET _search
{
    "query": {
    "function_score": {
        "functions": [
        {
            "linear": {
            "@timestamp" : {
                "origin": "1520627525000",
                        "scale": "1d",
                        "decay": 0.01
            }
            }
        }
        ],
        "score_mode" : "multiply",
        "boost_mode": "multiply",
        "query": {
            "bool": {
                 "must": [
                    { "term": { "prospector.type.keyword": "log" } },
                    { "term": { "source.keyword": """e:\program\wd\log.txt""" } },
                    { "term": { "host.keyword": "myhost" } }
                 ]
            }
        }
    }
    },
    "size": 1
}

然后我通常会在索引的开头获得日期,有人知道这种情况发生时如何获得更好的结果吗?或者是搜索时间点并获取最接近条目的更好方法。

如果需要,一些额外的信息。

0 个答案:

没有答案
相关问题