Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 弹性搜索中的大布尔问题_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch 弹性搜索中的大布尔问题,elasticsearch,elasticsearch" /> elasticsearch 弹性搜索中的大布尔问题,elasticsearch,elasticsearch" />

elasticsearch 弹性搜索中的大布尔问题

elasticsearch 弹性搜索中的大布尔问题,elasticsearch,elasticsearch,我需要从1024个以上的列表中获取至少包含一项的所有文档 我的查询基本上是一个bool查询,带有一个should和minimum\u should\u match:1 默认情况下,Elasticsearch maxClauseCount设置为1024。我已尝试将其设置为4096,配置看起来正常: 我请求并获得: 。。。 “查询”:{ “布尔”:{ “最大子句计数”:“4096” } } ..., 但是如果我仍然尝试在日志中获取TooManyClauses[maxClauseCount设置为10

我需要从1024个以上的列表中获取至少包含一项的所有文档

我的查询基本上是一个bool查询,带有一个shouldminimum\u should\u match:1

默认情况下,Elasticsearch maxClauseCount设置为1024。我已尝试将其设置为4096,配置看起来正常:

我请求并获得:

。。。
“查询”:{
“布尔”:{
“最大子句计数”:“4096”
}
}
...,
但是如果我仍然尝试在日志中获取
TooManyClauses[maxClauseCount设置为1024]

第一个问题:为什么这是矛盾的

我曾读到,在某些情况下,最好使用过滤器,而不是大型bool:

一般来说,我建议重写该查询以使用术语过滤器而不是布尔查询


第二个问题:在我的示例中,我如何使用过滤器获得与倍数相同的逻辑?对于这种情况,什么是最佳布尔过滤器或过滤过滤器?

我还不确定为什么Elasticsearch会引发maxClauseCount错误,但我找到了另一种方法来构造查询

(简单的)解决方案是将术语与大量项目一起使用。如果我将它用于
必须
中,我会得到相同的错误,但是使用
过滤器
时,它工作得非常好

例如:

{
  "query": {
    "bool": {
      "filter": [
        {"terms": {"my_field": ["item1", "item2", ... "itemN"]}}
      ]
    }
  }
}
过滤器的唯一缺陷是:

子句(查询)必须出现在匹配的文档中。但是,查询的分数将被忽略。


我还不确定为什么Elasticsearch会引发maxClauseCount错误,但我已经找到了另一种方法来构造我的查询

(简单的)解决方案是将术语与大量项目一起使用。如果我将它用于
必须
中,我会得到相同的错误,但是使用
过滤器
时,它工作得非常好

例如:

{
  "query": {
    "bool": {
      "filter": [
        {"terms": {"my_field": ["item1", "item2", ... "itemN"]}}
      ]
    }
  }
}
过滤器的唯一缺陷是:

子句(查询)必须出现在匹配的文档中。但是,查询的分数将被忽略。