Elastic Search High level Client for OSS 7.4

I am using Elasticsearch 7.4.0 OSS version server and want to connect via java rest api service.
So I used EL rest high level client

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>7.4.2</version>
</dependency>

but by creating client and using some request to create index I am getting an error

Forwarding to error page from request [/archive/index/create] due to exception [Invalid or missing build flavor [oss]]
ElasticsearchException[Invalid or missing build flavor [oss]]
	at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2084)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1732)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1717)```

and my service java code is
public class ElasticClientService {

public static RestHighLevelClient getHighLevelClient() {
	return new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9201, "http")));
}

public static boolean createIndex() {
	CreateIndexResponse createIndexResponse = null;
	CreateIndexRequest request = new CreateIndexRequest("archive01");
	request.settings(Settings.builder().put("index.number_of_shards", 3).put("index.number_of_replicas", 2));
	request.mapping("{\n" + "  \"properties\": {\n" + "    \"message\": {\n" + "      \"type\": \"text\"\n"
			+ "    }\n" + "  }\n" + "}", XContentType.JSON);
	try {
		createIndexResponse = getHighLevelClient().indices().create(request, RequestOptions.DEFAULT);

	} catch (IOException e) {
		e.printStackTrace();
		return false;
	}
	boolean acknowledged = createIndexResponse.isAcknowledged();
	boolean shardsAcknowledged = createIndexResponse.isShardsAcknowledged();
	if (acknowledged == true && shardsAcknowledged == true) {
		return true;
	}
	return false;
}

}

what should I do? Is it not allowed to use RHLC for OSS versions?

Are you sure you are using the version 7.4 of the client? I think you have a more recent one in your classpath.

It was issue of jar. I solved. Thanks.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.