我使用elasticsearch-java-client 7.17.4向AWS Elasticsearch服务器发出计数请求,如下代码所示
elasticsearchClient.count(s -> s
.index("my-index")
).count();
字符串
但是,发生了以下异常
Caused by: org.elasticsearch.client.ResponseException: method [POST],
host [https://my-host], URI [/my-index/_count], status line [HTTP/1.1 406 Not Acceptable]
{"error":"Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported","status":406}
型
看_count api at elasticsearch RestAPI reference听起来很奇怪,因为http方法是GET,但elasticsearch-java用POST发出请求。
有人有这个问题吗?
3条答案
按热度按时间ybzsozfc1#
我忘了一个重要的部分,响应机构都在说
字符串
解决方案
型
cu6pst1q2#
尝试将Java客户端API更新到版本8.2.2。我使用Java客户端API v8.2.2进行了测试。和ElasticSearch v7.17.1,它工作了。
pdtvr36n3#
我也遇到了同样的问题。然而,我的问题与elasticsearch的版本有关。我们有义务只使用
7.10.2
。我使用co.elastic.clients:elasticsearch-java:8.9.0
和scala org.scala-lang:scala-library:2.12.13
的版本在我修复了Content-type的问题之后,我又遇到了
X-Elastic-Product
的另一个问题。所以我必须做另一个修复来使用特定的elasticsearch版本。这个答案帮助了我:co.elastic.clients.transport.TransportException: [es/search] Missing [X-Elastic-Product] header
字符串