我希望在仪表板上设置过滤器,该仪表板将仅获取最新记录
因此在下面的DSL查询中使用
{
"query": {
"match_all": {}
},
"size": 1,
"sort": [
{
"_id": {
"order": "desc"
}
}
]
}
这在Elasticsearch Kibana 7.0中不起作用,我也已经在6.7.1中签入,它不起作用
"size" : 1 not working
当我在开发者工具中发布请求时,同样的方法
POST index/_search
{
"query": {
"match_all": {}
},
"size": 1,
"sort": [
{
"_id": {
"order": "desc"
}
}
]
}
但是它不适用于DSL查询。 参考:Get last document from ElasticSearch
Return the most recent record from ElasticSearch index
当我单击检查并检查请求时,我收到下面的请求,该请求没有我的尺寸过滤器
{
"version": true,
"size": 500,
"sort": [
{
"timestamp": {
"order": "desc",
"unmapped_type": "boolean"
}
}
],
"_source": {
"excludes": []
},
"aggs": {
"2": {
"date_histogram": {
"field": "timestamp",
"interval": "12h",
"time_zone": "Asia/Calcutta",
"min_doc_count": 1
}
}
},
"stored_fields": [
"*"
],
"script_fields": {
"StartTime": {
"script": {
"source": "return doc['timestamp'].value",
"lang": "painless"
}
},
"ExecDurn": {
"script": {
"source": "try{\n\tif (doc['endTime'].size() != 0 && doc['timestamp'].size() != 0) {\n\t\tChronoUnit.MILLIS.between(doc['timestamp'].value.toInstant(),doc['endTime'].value.toInstant())\n\t}\n}\ncatch (Exception ignored) {\n}",
"lang": "painless"
}
},
"EndTime": {
"script": {
"source": "try{\n\tif (doc['endTime'].size() != 0) {\n\t\tdoc['endTime'].value\n\t}\n\t}\ncatch (Exception ignored) {\n}",
"lang": "painless"
}
}
},
"docvalue_fields": [
{
"field": "endTime",
"format": "date_time"
},
{
"field": "timestamp",
"format": "date_time"
}
],
"query": {
"bool": {
"must": [
{
"range": {
"timestamp": {
"format": "strict_date_optional_time",
"gte": "2019-04-06T09:51:57.824Z",
"lte": "2019-04-21T09:51:57.824Z"
}
}
}
],
"filter": [
{
"match_all": {}
}
],
"should": [],
"must_not": []
}
},
"highlight": {
"pre_tags": [
"@kibana-highlighted-field@"
],
"post_tags": [
"@/kibana-highlighted-field@"
],
"fields": {
"*": {}
},
"fragment_size": 2147483647
}
}