[英]ElasticsearchException[Failed to parse info response. Check logs for detailed information - Unsupported Content-Type: text/html; charset=utf-8]
I'm using Elastic Java API in my project and there's a strange server error performing here.我在我的项目中使用 Elastic Java API,这里执行了一个奇怪的服务器错误。 For a reason "Accept" header doesn't work here while it's ok with Rest API.出于某种原因,“Accept”标头在这里不起作用,而 Rest API 可以。 Are there any options I should set also or instead of existing ones'?是否有任何我应该设置的选项或代替现有的选项?
Here is my code (I'm using Kotlin):这是我的代码(我正在使用 Kotlin):
fun search(
queryBuilder: QueryBuilder,
//index: String,
limit: Int? = null,
offset: Int? = null,
options: RequestOptions = RequestOptions
.DEFAULT
.toBuilder()
.addHeader("Accept", ContentType.APPLICATION_JSON.mimeType)
.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.mimeType)
.build()
): Array<out SearchHit> = ElasticConnection.connection {
val request = SearchSourceBuilder()
.query(queryBuilder)
.apply {
offset?.run(::from)
limit?.run(::size)
}
.let(SearchRequest().indices(index)::source)
search(request, options)
.hits
.hits
And here's a stack trace这是一个堆栈跟踪
java.lang.IllegalStateException: Unsupported Content-Type: text/html; charset=utf-8
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2008) ~[elasticsearch-rest-high-level-client-7.15.1.jar:7.15.1]
at org.elasticsearch.client.RestHighLevelClient.getVersionValidation(RestHighLevelClient.java:2161) ~[elasticsearch-rest-high-level-client-7.15.1.jar:7.15.1]
at org.elasticsearch.client.RestHighLevelClient.access$100(RestHighLevelClient.java:253) ~[elasticsearch-rest-high-level-client-7.15.1.jar:7.15.1]
at org.elasticsearch.client.RestHighLevelClient$5.onSuccess(RestHighLevelClient.java:2123) ~[elasticsearch-rest-high-level-client-7.15.1.jar:7.15.1]
at org.elasticsearch.client.RestClient$FailureTrackingResponseListener.onSuccess(RestClient.java:636) ~[elasticsearch-rest-client-7.15.1.jar:7.15.1]
at org.elasticsearch.client.RestClient$1.completed(RestClient.java:376) ~[elasticsearch-rest-client-7.15.1.jar:7.15.1]
at org.elasticsearch.client.RestClient$1.completed(RestClient.java:370) ~[elasticsearch-rest-client-7.15.1.jar:7.15.1]
at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:122) ~[httpcore-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:181) ~[httpasyncclient-4.1.4.jar:4.1.4]
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:448) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:338) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81) ~[httpasyncclient-4.1.4.jar:4.1.4]
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39) ~[httpasyncclient-4.1.4.jar:4.1.4]
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104) ~[httpcore-nio-4.4.13.jar:4.4.13]
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591) ~[httpcore-nio-4.4.13.jar:4.4.13]
at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
}
In my case, I had used the wrong config for Elasticsearch host.就我而言,我为 Elasticsearch 主机使用了错误的配置。 I had set the host
endpoint to that of Kibana instead of Elasticsearch.我已将host
端点设置为 Kibana 而不是 Elasticsearch。
Kibana endpoint: <cluster-name>.kb.us-east-1.aws.found.io:9243
Kibana 端点: <cluster-name>.kb.us-east-1.aws.found.io:9243
ES endpoint: <cluster-name>.es.us-east-1.aws.found.io:9243
ES 端点: <cluster-name>.es.us-east-1.aws.found.io:9243
Notice the kb
vs es
in the endpoints.注意端点中的kb
与es
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.