以下是 msearch post 调用的请求负载:-
{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"*****"}
{
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "1710391896481",
"lte": "1710413496481",
"format": "epoch_millis"
}
}
},
{
"query_string": {
"analyze_wildcard": true,
"query": "*"
}
}
]
}
},
"aggs": {
"2": {
"date_histogram": {
"fixed_interval": "30s",
"field": "@timestamp",
"min_doc_count": 0,
"extended_bounds": {
"min": "1710391896481",
"max": "1710413496481"
},
"format": "epoch_millis"
},
"aggs": {}
}
}
}
这只在页面加载期间失败一次,之后相同的 api 就可以正常工作了。
API 错误
{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "key [size] is not supported in the metadata section" } ], "type": "illegal_argument_exception", "reason": "key [size] is not supported in the metadata section" }, "status": 400 }
关于如何解决这个问题有什么建议吗?
这里有一些提高搜索速度的技巧。
query_string
,因为它会使用 *
过滤所有内容。1710413496481 - 1710391896481 = 21.600.000 毫秒 = 21.600 秒
21.600 秒/每个桶 30 秒 = 720 个桶
要减少桶的数量,您可以增加
中的fixed_interval
aggs 或减少date_histogram
和max
之间的时间差 时间戳。min