# Migration from HighRestLevelCLient to ElasticSearchClient

**URL:** <https://discuss.elastic.co/t/migration-from-highrestlevelclient-to-elasticsearchclient/335023>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 1, 2023, 5:11pm UTC](https://discuss.elastic.co/t/migration-from-highrestlevelclient-to-elasticsearchclient/335023 "2023-06-01T17:11:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![neodeveloper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neodeveloper/32/121762_2.png) [@neodeveloper](https://discuss.elastic.co/u/neodeveloper)\
**Post date:** [June 1, 2023, 5:11pm UTC](https://discuss.elastic.co/t/migration-from-highrestlevelclient-to-elasticsearchclient/335023/1 "2023-06-01T17:11:55Z")

</div>

Good morning,  
We are planning to upgrade to springboot3.0 and we are heavily using the deprecated client named HighRestLevelClient which is removed in springboot3 and replaced with the new java api client named ElasticSearchClient. however, we are runinng into some troubles because there is a big lag between the two clients.  
For example, our application creates indexes along with ilm policies (index lifecycle management) in this way

```auto
private static void createIlmPolicy(RestHighLevelClient elasticClient, ElasticProperties elasticProperties) throws IOException {

        if (elasticProperties.getIndexPolicies() != null) {
            IndexLifecycleNamedXContentProvider indexLifecycleNamedXContentProvider = new IndexLifecycleNamedXContentProvider();
            NamedXContentRegistry registry = new NamedXContentRegistry(indexLifecycleNamedXContentProvider.getNamedXContentParsers());

            for (IndexPolicy p : elasticProperties.getIndexPolicies()) {

                elasticClient.indexLifecycle().putLifecyclePolicy(
                        new PutLifecyclePolicyRequest(
                                LifecyclePolicy.parse(
                                        JsonXContent.jsonXContent.createParser(registry, LoggingDeprecationHandler.INSTANCE, jsonMapper.writeValueAsString(p.getPolicy())),
                                        p.getName()
                                )
                        ),
                        RequestOptions.DEFAULT
                );
            }
        }
    }

```

How can we do this with the new java client, knowing that there is nomore indexLifecycle() ,putLifecyclePolicy() methods availble in the java api client?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [June 6, 2023, 8:21am UTC](https://discuss.elastic.co/t/migration-from-highrestlevelclient-to-elasticsearchclient/335023/2 "2023-06-06T08:21:47Z")

</div>

This should look like this:

```java
private static void createIlmPolicy(ElasticsearchClient elasticClient, ElasticProperties elasticProperties) throws IOException {
    if (elasticProperties.getIndexPolicies() != null) {

        for (IndexPolicy p : elasticProperties.getIndexPolicies()) {

            elasticClient.ilm().putLifecycle(l -> l
                .name(p.getName())
                .withJson(new StringReader(p.getPolicy()))
            );
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 4, 2023, 8:22am UTC](https://discuss.elastic.co/t/migration-from-highrestlevelclient-to-elasticsearchclient/335023/3 "2023-07-04T08:22:25Z")

</div>

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