elasticsearch - Elasticsearch 避免聚合中的 maxClauseCount 错误
问题描述
我有一个索引,其中包含 Elasticsearch 5.X 中的以下文档。
它将文档文件的一行字符串作为单个记录保存。
{"file_id":"file0001", "row_id":"1", "text":"(text field to search...)"}
{"file_id":"file0001", "row_id":"2", "text":"(text field to search...)"}
{"file_id":"file0001", "row_id":"3", "text":"(text field to search...)"}
{"file_id":"file0002", "row_id":"1", "text":"(text field to search...)"}
{"file_id":"file0002", "row_id":"2", "text":"(text field to search...)"}
...Millions of documents...
并发送以下查询以提取每个文件的前 500 个命中行。
{
"_source":[
"file_id",
"text"
],
"size":0,
"query":{
"filtered":{
"query"{
"must":{
"regexp":{
"text":".*[o2].*"
}
}
},
"filter":{
"terms":{
"file_id":[
(Thousands of file_ids...)
]
}
}
}
},
"aggs":{
"top-docs":{
"terms":{
"field":"file_id",
"size":5000
},
"aggs":{
"top_file_hits":{
"top_hits":{
"size":500,
"highlight":{
"pre_tags":["<em>"],
"post_tags":["</em>"],
"fields":{
"text":{}
}
}
}
}
}
}
}
}
然后返回以下错误。
{
"error" : {
"root_cause" : [
{
"type" : "too_many_clauses",
"reason" : "maxClauseCount is set to 1024"
我认为 aggs 过程很重,但我想不出不使用它的方法。有任何想法吗?
解决方案
推荐阅读
- git - PhpStorm 添加冲突文件
- android - 联系人服务:等待 ContactsService.getContacts() 太慢了
- python - (TwitchIO for Python)导入命令时出现无效语法错误
- android - 如何在 Android 的 Razorpay 中指定自定义付款方式
- python - Flask-limiter - 如何找到 Flask-limiter 在 Redis 中存储的键名
- java - Lists.addAll(Map.get(key)),无意中改变了`Map`
- java - I don't understand how this line works: "System.out.println("\nCard: " + Deck.get(number).getValue() + " of " + Deck.get(number).getSuit() );"
- javascript - Express POST 无法识别字符串
- airflow - 如何从 Apache Airflow 调用外部服务器(在每次 DAG 运行之后)
- python-3.x - 用python3中的正则表达式匹配句子中的变体名称字符串