【问题标题】:ElasticSearch query with date and term带有日期和期限的 ElasticSearch 查询
【发布时间】:2015-12-10 05:10:58
【问题描述】:

这是我的查询

{
    "filter": {
        "bool": {
            "must": [{
                "range": {
                    "timestamp": {
                        "gte": "now-24"
                    }
                }
            }, {
                "term": {
                    "program": "dashboard"
                }
            }]
        }
    }
}

elasticsearch 中的数据样本:

 {
"_index": "logstash-2015.09.14",
"_type": "logs",
"_id": "AU_MPG6xoSXeyoJeeaQ1",
"_score": 1,
"_source": {
"message": "testing for clustering--473983--https://github.com/mobz/elasticsearch-headThis will automatically download the latest version of elasticsearch-head from github and run it as ugin within the elasticsearch cluster.",
"@version": "1",
"@timestamp": "2015-09-14T14:23:16.000Z",
"host": "172.17.42.1",
"priority": 13,
"timestamp": "Sep 14 14:23:16",
"logsource": "cn1",
"program": "ubuntu",
"severity": 5,
"facility": 1,
"facility_label": "user-level",
"severity_label": "Notice",
"event_time": "2015-09-14 14:23:16 UTC"
}
}

我怎样才能通过`

从现在到现在

in this query if timestamp in"timestamp": "Sep 14 06:19:10"` 这个格式请大家帮帮我。

【问题讨论】:

  • 索引时时间戳字段的格式是什么,是否有日期类型的映射?
  • @keety 这是logstash数据所以我不知道。

标签: ruby json elasticsearch


【解决方案1】:

你可能会使用:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "program": "dashboard"
                    }
                },
                {
                    "range": {
                        "@timestamp": {
                            "from": "2015-09-14T20:56:52.404Z",
                            "to": "2015-09-14T20:57:02.686Z"
                        }
                    }
                }
            ]
        }
    }
}

问候, 阿兰

【讨论】:

  • 您能与我们分享您使用的查询吗?执行中是否有错误?
  • {"from":0,"size":10000,"filter":{"bool":{"must":[{"range":{"event_time":{"from" :"13/09/2015","to":"14/09/2015","格式":"dd/MM/yyyy"}}},{"term":{"program":"ubuntu"} }]}}} 并且没有错误发生
  • 如果你想过滤 event_time 字段,试试这个: { "query": { "bool": { "must": [ { "term": { "program": "dashboard" } } , { "range": { "logs.event_time": { "from": "2015-09-13", "to": "2015-09-14" } } } ] } } }
【解决方案2】:

如果你想过滤 event_time 字段,试试这个:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "program": "dashboard"
                    }
                },
                {
                    "range": {
                        "logs.event_time": {
                            "from": "2015-09-13",
                            "to": "2015-09-14"
                        }
                    }
                }
            ]
        }
    }
}

问候, 阿兰

【讨论】:

    猜你喜欢
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    相关资源
    最近更新 更多