gpt4 book ai didi

elasticsearch 得到太多结果,需要帮助过滤查询

转载 作者:行者123 更新时间:2023-11-29 02:46:17 25 4
gpt4 key购买 nike

我在理解 ES 查询系统的底层方面遇到很多问题。

例如,我有以下查询:

{
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"referer": "www.xx.yy.com"
}
},
{
"range": {
"@timestamp": {
"gte": "now",
"lt": "now-1h"
}
}
}
]
}
},
"aggs": {
"interval": {
"date_histogram": {
"field": "@timestamp",
"interval": "0.5h"
},
"aggs": {
"what": {
"cardinality": {
"field": "host"
}
}
}
}
}
}

该请求得到太多结果:

"status" : 500, "reason" : "ElasticsearchException[org.elasticsearch.common.breaker.CircuitBreakingException: Data too large, data for field [@timestamp] would be larger than limit of [3200306380/2.9gb]]; nested: UncheckedExecutionException[org.elasticsearch.common.breaker.CircuitBreakingException: Data too large, data for field [@timestamp] would be larger than limit of [3200306380/2.9gb]]; nested: CircuitBreakingException[Data too large, data for field [@timestamp] would be larger than limit of [3200306380/2.9gb]]; "

我已经尝试过这个请求:

{
"size": 0,
"filter": {
"and": [
{
"term": {
"referer": "www.geoportail.gouv.fr"
}
},
{
"range": {
"@timestamp": {
"from": "2014-10-04",
"to": "2014-10-05"
}
}
}
]
},
"aggs": {
"interval": {
"date_histogram": {
"field": "@timestamp",
"interval": "0.5h"
},
"aggs": {
"what": {
"cardinality": {
"field": "host"
}
}
}
}
}
}

我想过滤数据以获得正确的结果,我们将不胜感激!

最佳答案

我找到了一个解决方案,这有点奇怪。我听从了 dimzak 的建议并清除了缓存:

curl --noproxy localhost -XPOST "http://localhost:9200/_cache/clear"

然后我使用过滤而不是 Olly 建议的查询:

{
"size": 0,
"query": {
"filtered": {
"query": {
"term": {
"referer": "www.xx.yy.fr"
}
},
"filter" : {
"range": {
"@timestamp": {
"from": "2014-10-04T00:00",
"to": "2014-10-05T00:00"
}
}
}
}
},
"aggs": {
"interval": {
"date_histogram": {
"field": "@timestamp",
"interval": "0.5h"
},
"aggs": {
"what": {
"cardinality": {
"field": "host"
}
}
}
}
}
}

我不能给你们两个答案,我认为 dimzak 应该得到最好的答案,但对你们两个人竖起大拇指:)

关于elasticsearch 得到太多结果,需要帮助过滤查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27296340/

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