Elasticsearch 异常 [type=parsing_exception, reason=[wildcard] 查询不支持 [case_insensitive]]

Elasticsearch exception [type=parsing_exception, reason=[wildcard] query does not support [case_insensitive]]

我正在使用 Maven-org-elasticsearch-client_elasticsearch-rest-high-level-client 版本的 7.10.2 版本并且 WildcardQueryBuilder 应该与 caseInsensitive 属性 一起使用。以下是我的代码片段,在执行我的 ES 搜索请求时出现“Elasticsearch 异常 [type=parsing_exception,原因=[通配符] 查询不支持 [case_insensitive]]”

private BoolQueryBuilder translateSearchFilter(final Filter filter) {
        final BoolQueryBuilder searchQuery = new BoolQueryBuilder();
        searchQuery.must(new WildcardQueryBuilder(filter.getDimension(), filter.getQuery().getValue())
                .caseInsensitive(!filter.getQuery().isCaseSensitive()));
        return searchQuery;
    }

异常日志

"exception": " ElasticsearchStatusException[Elasticsearch exception [type=x_content_parse_exception, reason=[1:102] [bool] failed to parse field [must]]]; nested: ElasticsearchException[Elasticsearch exception [type=parsing_exception, reason=[wildcard] query does not support [case_insensitive]]];\n\tat org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:187)\n\tat org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1911)\n\tat org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1888)\n\tat org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1645)\n\tat org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1602)\n\tat org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1572)\n\tat org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:1088)\n\tat com.amazon.atvomniaservice.elasticsearch.ElasticSearchClient.search(ElasticSearchClient.java:52)\n\tat com.amazon.atvomniaservice.elasticsearch.ElasticSearchQueryRunner.submit(ElasticSearchQueryRunner.java:30)\n\tat 

我坚信 Java 客户端版本和您的集群版本不同。 caseInsensitive 查询参数首次在 Elasticsearch 版本 7.10 中引入。

所以我猜你是 运行 版本低于 7.10 的 Elasticsearch 集群。集群“还”不知道这个参数。

希望能帮到你