[英]ElasticSearch query with date and term
Here is my query 这是我的查询
{
"filter": {
"bool": {
"must": [{
"range": {
"timestamp": {
"gte": "now-24"
}
}
}, {
"term": {
"program": "dashboard"
}
}]
}
}
}
Data sample in elasticsearch: 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"
}
}
How can I pass ` 我该如何通过`
from and to date
从至今
in this query if timestamp in
"timestamp": "Sep 14 06:19:10"` this format please someone help me. in this query if timestamp in
“ timestamp”:“ Sep 14 06:19:10”`,请有人帮助我。
You might use: 您可以使用:
{
"query": {
"bool": {
"must": [
{
"term": {
"program": "dashboard"
}
},
{
"range": {
"@timestamp": {
"from": "2015-09-14T20:56:52.404Z",
"to": "2015-09-14T20:57:02.686Z"
}
}
}
]
}
}
}
Regards, Alain 问候,阿兰
If you want to filter on event_time field, try this: 如果要过滤event_time字段,请尝试以下操作:
{
"query": {
"bool": {
"must": [
{
"term": {
"program": "dashboard"
}
},
{
"range": {
"logs.event_time": {
"from": "2015-09-13",
"to": "2015-09-14"
}
}
}
]
}
}
}
Regards, Alain 问候,阿兰
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.