I have a test project with the following configuration:
The connection to OpenSearch is configured like this:
@Configuration
class OpensearchConfig: ReactiveElasticsearchConfiguration() {
val httpHeaders = HttpHeaders()
httpHeaders.add("Content-type", "application/json")
override fun clientConfiguration(): ClientConfiguration {
val config = ClientConfiguration.builder()
.connectedTo("localhost:9200")
.usingSsl()
.withDefaultHeaders(httpHeaders)
.withBasicAuth("admin", "admin")
.build()
return config
}
}
I'm trying to save a simple entity:
val isIndexExists = opensearch.indexOps(Person::class.java).exists().awaitSingle()
if (!isIndexExists) {
opensearch.indexOps(Person::class.java).create().subscribe()
}
opensearch.save(Person(UUID.randomUUID().toString(), name))
.doOnNext(System.out::println)
.subscribe()
And I got the following error:
org.springframework.dao.DataAccessResourceFailureException: status: 200, [es/indices.exists] Missing [X-Elastic-Product] header. Please check that you are connecting to an Elasticsearch instance, and that any networking filters are preserving that header.; nested exception is java.lang.RuntimeException: status: 200, [es/indices.exists] Missing [X-Elastic-Product] header. Please check that you are connecting to an Elasticsearch instance, and that any networking filters are preserving that header.] with root cause
I didn't find an answer in the documentation whether spring-boot-starter-data-elasticsearch supports OpenSearch, so I had a question - maybe I'm configuring the connection to OpenSearch incorrectly? Or do I need to use opensearch-rest-client instead of spring-boot-starter-data-elasticsearch?
Spring Data Elasticsearch is built against Elasticsearch servers using Elasticsearch client libraries.
You might want to check out spring-data-opensearch https://github.com/opensearch-project/spring-data-opensearch