'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. For a reason "Accept" header doesn't work here while it's ok with Rest API. Are there any options I should set also or instead of existing ones'?
Here is my code (I'm using 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]
}
Solution 1:[1]
In my case, I had used the wrong config for Elasticsearch host. I had set the host endpoint to that of Kibana instead of Elasticsearch.
Kibana endpoint: <cluster-name>.kb.us-east-1.aws.found.io:9243
ES endpoint: <cluster-name>.es.us-east-1.aws.found.io:9243
Notice the kb vs es in the endpoints.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sumit Jha |
