# Java rest client 5.6, fetch if "Type" exists

**URL:** <https://discuss.elastic.co/t/java-rest-client-5-6-fetch-if-type-exists/134020>\
**Category:** Elasticsearch\
**Created:** [May 31, 2018, 10:26am UTC](https://discuss.elastic.co/t/java-rest-client-5-6-fetch-if-type-exists/134020 "2018-05-31T10:26:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neha\_goswami](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@Neha\_goswami](https://discuss.elastic.co/u/Neha_goswami)\
**Post date:** [May 31, 2018, 10:26am UTC](https://discuss.elastic.co/t/java-rest-client-5-6-fetch-if-type-exists/134020/1 "2018-05-31T10:26:50Z")

</div>

I am working on migration from Transport client to rest client:  
To start with the simple change:  
earlier in transport client to find a "type" exists ,we did this:

boolean typexists = this.client.admin().indices().prepareTypesExists("recovery\_index").setTypes("recovery\_type").get(TimeValue.timeValueSeconds(this.timeoutSecs)).isExists();

how do we achieve this using restClient? In rest Client we can get this as response:

Response response=restClient.performRequest("GET", "/recovery\_index/recovery\_type/\_search", Collections.singletonMap("pretty", "true"));

now further from this response any quicker way to get if type exists??

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [June 8, 2018, 11:01am UTC](https://discuss.elastic.co/t/java-rest-client-5-6-fetch-if-type-exists/134020/2 "2018-06-08T11:01:00Z")

</div>

Types exists can be done through a HEAD request to the /{index}/\_mapping/{type} endpoint. It will return no response body, but the returned status code will tell you whether the type exists (200) or not (404).

---

<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 6, 2018, 11:01am UTC](https://discuss.elastic.co/t/java-rest-client-5-6-fetch-if-type-exists/134020/3 "2018-07-06T11:01:04Z")

</div>

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