Search code examples
spring-bootelasticsearchspring-data-elasticsearchaws-elasticsearchspring-autoconfiguration

Issue connecting Springboot 2.7.8 with AWS Elasticsearch : ElasticsearchException[Invalid or missing build flavor [oss]]


I've upgraded my Springboot version to 2.7.8, spring-data-elasticsearch version to 4.4.7 and org.elasticsearch --- elasticsearch to 7.17.3

Here are the dependencies in my pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.8</version>
    <relativePath />
</parent>

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-elasticsearch</artifactId>
    <version>4.4.7</version>
</dependency>

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>7.17.3</version>
</dependency>

This compatibility matrix is from the official docs: https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#preface.versions

My AWS Elasticsearch instance version is on version 6.2, for testing I've created another instance with version 7.10 also.

The issue is I'm not able to establish a connection with any of the AWS Elasticsearch instances with the 6.2 or 7.10 version.

It's failing with the error:

Invalid or missing build flavor [oss]; nested exception is ElasticsearchException[Invalid or missing build flavor [oss]]

Also wanted to clarify one doubt, under the application.properties:

spring.elasticsearch.uris = [AWS-Instance-URL]

Do we have to append any port number at the end of the URL, Eg. [AWS-Instance-URL : {9200/ 443}]?

Cause if I'm not providing any port number, it is somehow autoconfiguring to -1 port

Failed to instantiate [org.springframework.data.elasticsearch.client.ClientConfiguration]: Factory method 'clientConfiguration' threw exception; nested exception is java.lang.IllegalArgumentException: Port number out of range: AWS-Instance_URL:-1

Please can someone provide some insights on this and show some direction with the current configuration on how can I establish the connection with AWS Elasticsearch?

Thank you!


Solution

  • The error you see comes from changes that Elasticsearch introduced in the client with the 7.10 version if I remember correctly. Check https://stackoverflow.com/a/74441976/4393565 and https://github.com/elastic/elasticsearch/issues/76091. They added some license checking to their client code. You find quite some questions here on SO with that topic (https://stackoverflow.com/search?q=Invalid+or+missing+build+flavor+oss).

    Spring Data Elasticsearch is built and tested with the official releases from Elasticsearch, I don't know if AWS Elasticsearch is available in 7.17, and if the client library checks for the build flavour as well.

    AWS created their Opensearch variant of Elasticsearch around the time of that changes, and there is the https://github.com/opensearch-project/spring-data-opensearch project that builds on Spring Data Elasticsearch (not maintained by me), but I don't know either if this would work against your server version.

    BTW: You are upgrading to a version that is out of maintenance.