gpt4 book ai didi

elasticsearch - 在Kibana 7/6.7.2中设置过滤器,以获取DSL中大小为1的最新_id

转载 作者:行者123 更新时间:2023-12-02 22:35:34 24 4
gpt4 key购买 nike

我希望在仪表板上设置过滤器,该仪表板将仅获取最新记录

所以用下面的DSL查询

{
"query": {
"match_all": {}
},
"size": 1,
"sort": [
{
"_id": {
"order": "desc"
}
}
]
}

这在Elasticsearch Kibana 7.0中不起作用,我也已经在6.7.1中 checkin 了,它不起作用
"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
}
}

最佳答案

默认情况下,“发现” View 将显示500条记录。您可以通过以下方法修改该设置:转到管理>高级设置,然后将“行数”设置更改为1。

number of rows

关于elasticsearch - 在Kibana 7/6.7.2中设置过滤器,以获取DSL中大小为1的最新_id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55729090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com