1.异常
elasticsearch 报错如下:
Caused by: ElasticsearchStatusException[Elasticsearch exception [type=parsing_exception, reason=[multi_match] query does not support [auto_generate_synonyms_phrase_query]]]
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:187)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1892)
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1869)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1626)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1583)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1553)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:1069)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.lambda$search$10(ElasticsearchRestTemplate.java:256)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.execute(ElasticsearchRestTemplate.java:343)
... 69 more
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://192.168.10.6:9200], URI [/filesearch/_search?typed_keys=true&max_concurrent_shard_requests=5&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&search_type=dfs_query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[multi_match] query does not support [auto_generate_synonyms_phrase_query]","line":1,"col":307}],"type":"parsing_exception","reason":"[multi_match] query does not support [auto_generate_synonyms_phrase_query]","line":1,"col":307},"status":400}
at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:302)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:272)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:246)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1613)
... 74 more
2.配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
版本是2.4.1
进去
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>transport</artifactId>
<groupId>org.elasticsearch.client</groupId>
</exclusion>
</exclusions>
</dependency>
3.解决方法
把elasticsearch版本改到6
docker run -itd --name es-file-manage --network net-platform --ip 192.168.10.6 -e "discovery.type=single-node" elasticsearch:6.8.22
抛出异常
contains unrecognized parameter: [ccs_minimize_roundtrips]]]
只好先去查版本对应关系
https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#preface.versions
所以我需要一个7.9.3版本的 elasticsearch
docker run -itd --name es-file-manage --network net-platform --ip 192.168.10.6 -e "discovery.type=single-node" elasticsearch:7.9.3