gpt4 book ai didi

elasticsearch - Elasticsearch 通配符查询使集群崩溃

转载 作者:行者123 更新时间:2023-12-03 00:01:23 30 4
gpt4 key购买 nike

我在大型 flex 搜索集群上运行以下查询。群集无响应

{
"size": 10000,
"query": {
"bool": {
"must": [
{
"regexp": {
"message": {
"value": ".*exception.*"
}
}
},
{
"bool": {
"should": [
{
"term": {
"beat.hostname": "ip-xxx-xx-xx-xx"
}
}
]
}
},
{
"range": {
"@timestamp": {
"lt": 1518459660000,
"format": "epoch_millis",
"gte": 1518459600000
}
}
}
]
}
}
}

当我删除通配符 .*exception.*并将其替换为任何非通配符字符串(如 xyz)时,它会快速返回。尽管查询使用通配符表达式,但它还会查找较小的时间范围和特定的主机。我认为这是一个非常简单的查询。 Elasticsearch服务器无法处理此查询的任何原因?群集具有10个节点和20 TB的数据。

最佳答案

参见documentation for Regexp Query。它明确指出以下内容:

Note: The performance of a regexp query heavily depends on the regular expression chosen. Matching everything like .* is very slow



理想的是使用 WordDelimiterTokenFilter更改 message字段上的文本分析,并将 split_on_case_change设置为true。然后像 NullPointerException这样的东西将被索引为三个单独的 token [Null, Pointer, Exception]。这可以帮助您在不使用正则表达式的情况下搜索 exception。请注意,您需要重新索引所有文档。

另一快速尝试是将过滤条件保留在主机名和时间戳记中的 filter context中,这将在运行regexp查询之前对文档进行预过滤。在您修复文本分析之前,这可能是您的短期解决方案。

关于elasticsearch - Elasticsearch 通配符查询使集群崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48780372/

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