Should clauses in the filter context will no longer automatically set the minimum 【ElasticSearch】

痛定思痛。 2024-04-08 09:45 149阅读 0赞

【已解决】

文章目录

    • 背景
    • 异常信息
    • 原因
      • 官方文档
    • 解决

背景

es版本升级,es v5.6.1 —》》 es v5.8.2


异常信息

2022-08-18 11:30:48.455 WARN 16 – [I/o dispatcher 4] org.elasticsearch.client.Restclient: request [POST http://test-index/type/\_search?typedkeys=truesignore _unavailable=falsesexpand_wildcards=opensallow_no_indices=true&search_type=query_then fetchabatched_reduce_size=512] returned 1 warnings: [299 Elasticsearch-6.8.2-b506955 “Should clauses in the filter context will no longer automatically set the minimum should match to 1 in the next major version. You should group them in a [filter] clause or explicitly set [minimum_should_match] to 1 to restore this behavior in the next major version. “]

  1. 2022-08-18 11:30:48.455 WARN 16 -- [I/o dispatcher 4] org.elasticsearch.client.Restclient: request [POST http://test-index/type/_search?typedkeys=truesignore _unavailable=falsesexpand_wildcards=opensallow_no_indices=true&search_type=query_then fetchabatched_reduce_size=512] returned 1 warnings: [299 Elasticsearch-6.8.2-b506955 "Should clauses in the filter context will no longer automatically set the minimum should match to 1 in the next major version. You should group them in a [filter] clause or explicitly set [minimum_should_match] to 1 to restore this behavior in the next major version. "]

原因

在这里插入图片描述

可以参考:https://blog.csdn.net/xiao\_jun\_0820/article/details/51095521

官方文档

参看elasticsearch官方文档,对should的说明以下:json

shouldapp
The clause (query) should appear in the matching document. If the bool query is in a query context and has a must or filter clause then a document will match the bool query even if none of the should queries match. In this case these clauses are only used to influence the score. If the bool query is a filter context or has neither must or filter then at least one of the should queries must match a document for it to match the bool query. This behavior may be explicitly controlled by settings the minimum_should_match parameter.less

表达的意思是:若是一个query语句的bool下面,除了should语句,还包含了filter或者must语句,那么should context下的查询语句能够一个都不知足,只是_score=0,因此上述查询语句,有无should语句,查询到的hits().total()是同样的,只是score不一样而已。

解决

这是一个警告⚠内容,不影响查询,在新的版本中不建议使用。

发表评论

表情:
评论列表 (有 0 条评论,149人围观)

还没有评论,来说两句吧...

相关阅读