# Cluster-health check with elasticsearch-java against 7.x cluster

**URL:** <https://discuss.elastic.co/t/cluster-health-check-with-elasticsearch-java-against-7-x-cluster/375724>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 11, 2025, 4:05pm UTC](https://discuss.elastic.co/t/cluster-health-check-with-elasticsearch-java-against-7-x-cluster/375724 "2025-03-11T16:05:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Kruse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hans_kruse/32/54739_2.png) [@Hans\_Kruse](https://discuss.elastic.co/u/Hans_Kruse)\
**Post date:** [March 11, 2025, 4:05pm UTC](https://discuss.elastic.co/t/cluster-health-check-with-elasticsearch-java-against-7-x-cluster/375724/1 "2025-03-11T16:05:15Z")

</div>

Getting cluster health from an es-7 cluster using the `elasticsearch-java` (es8) language client does not work out of the box. How do I configure the client in a compatible way?

We are finishing our migration from es7 clients to the newer elasticsearch-java client for es8.

I would like to return a cluster health response using the `elasticsearch-java`, es8 client talking to an es7 server cluster using the following code:

```Java
@Service
public class OurService {
  //...
  private final ElasticsearchClient client;
 //...

    @Autowired
    public OurService(final @NotNull ElasticsearchClient client) {
      //...
        this.client = client;
    }

    public HealthResponse getHealth() throws IOException {
        return this.client.cluster().health();
    }
//...
}

```

I configured the client as follows:

```Java
//...
  public static @NotNull ElasticsearchClient createElasticsearchClient(
   final @NotNull RestClient restClient,
   final @NotNull JacksonJsonpMapper jacksonJsonpMapper) {
        //final var transport = new RestClientTransport(restClient, jacksonJsonpMapper); //original code
        final TransportOptions transportOptions = null;//How to configure the TransportOptions?
        final var transport = new RestClientTransport(restClient, jacksonJsonpMapper, transportOptions);
        return new ElasticsearchClient(transport);
    }
//...

```

How should I configure the TransportOptions?  
Here all kinds of AI hallucinate the most beautiful non-existing solutions.

Some human guidance is appreciated here.

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [March 11, 2025, 5:15pm UTC](https://discuss.elastic.co/t/cluster-health-check-with-elasticsearch-java-against-7-x-cluster/375724/2 "2025-03-11T17:15:01Z")

</div>

Hello!

As a human developer, I'm sorry to say that this is a known incompatibility between version 8 of the java client and version 7 of the server.

Elasticsearch server version 8 has a new required property, `unassigned_primary_shards`, which we require in the client version 8 as well; consequently, calling cluster health will fail with `Missing required property 'HealthResponse.unassignedPrimaryShards'`.

As stated in the compatibility section of the [readme](https://github.com/elastic/elasticsearch-java?tab=readme-ov-file#compatibility), the client is forward compatible, so there's no guarantee it will work with older versions of the server.

For some cases there is a workaround consisting in disabling the "required properties" check, but it doesn't work with primitive types, which is the case here - we do have plans to make it work in this situations too.
