# ElasticSearchRepository usage in java low level client

**URL:** <https://discuss.elastic.co/t/elasticsearchrepository-usage-in-java-low-level-client/312346>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 18, 2022, 6:56am UTC](https://discuss.elastic.co/t/elasticsearchrepository-usage-in-java-low-level-client/312346 "2022-08-18T06:56:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gowri\_Shankkari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gowri_shankkari/32/98669_2.png) [@Gowri\_Shankkari](https://discuss.elastic.co/u/Gowri_Shankkari)\
**Post date:** [August 18, 2022, 6:56am UTC](https://discuss.elastic.co/t/elasticsearchrepository-usage-in-java-low-level-client/312346/1 "2022-08-18T06:56:26Z")

</div>

I am using 'elasticsearch-rest-client:8.3.3' to connect elasticsearch using java low level rest client. Is there a way to use ElasticsearchRepository (@Document annotation) when using low level rest client. I know it is possible when using High Level Rest Client as below

//Repository class

```auto
@Repository
public interface MessageRepository extends ElasticsearchRepository<DemoMessage, Long> {}

```

//Configuration class

```auto
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.demo.elasticsearch.repositories")
@ComponentScan(basePackages = {"com.demo.elasticsearch"})
public class ElasticSearchConfiguration {

    @Bean
    public RestHighLevelClient elasticsearchClient() {...}

}

```

Thanks!

---

<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:** [August 18, 2022, 8:20am UTC](https://discuss.elastic.co/t/elasticsearchrepository-usage-in-java-low-level-client/312346/2 "2022-08-18T08:20:25Z")

</div>

`Repository` comes from Spring Data Elasticsearch and not High Level Rest Client.

The Low Level Rest Client is – as its name implies – low level. So it only deals with raw http requests and responses. So no, no repository at that level.

---

<div class="post-metadata">

**Author:** ![Gowri\_Shankkari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gowri_shankkari/32/98669_2.png) [@Gowri\_Shankkari](https://discuss.elastic.co/u/Gowri_Shankkari)\
**Post date:** [August 19, 2022, 6:22am UTC](https://discuss.elastic.co/t/elasticsearchrepository-usage-in-java-low-level-client/312346/3 "2022-08-19T06:22:15Z")

</div>

So it is not possible to use spring-boot-starter-data-elasticsearch features when using low level rest client? Is there a way to send request like below using low level client.

```auto
 SearchResponse response = client.prepareSearch("kal").setTypes("products")
            .setSearchType(SearchType.DEFAULT)
            .setQuery(qb)
            .get();

```

I have been using below code for sending request.

```auto
Request req = new Request(HttpMethod.PUT.name(), MESSAGE_INDEX + "/_doc/" + message.getId());
            ObjectMapper mapper = new ObjectMapper();
            String jsonObj = mapper.writeValueAsString(message);
            req.setJsonEntity(jsonObj);
            Response resp = client.performRequest(req);

```

Thanks!!

---

<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:** [September 16, 2022, 6:23am UTC](https://discuss.elastic.co/t/elasticsearchrepository-usage-in-java-low-level-client/312346/4 "2022-09-16T06:23:05Z")

</div>

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