# Best practice to check if mapping exists?

**URL:** <https://discuss.elastic.co/t/best-practice-to-check-if-mapping-exists/14461>\
**Category:** Elasticsearch\
**Created:** [November 19, 2013, 8:19am UTC](https://discuss.elastic.co/t/best-practice-to-check-if-mapping-exists/14461 "2013-11-19T08:19:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Kley](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Alexander\_Kley](https://discuss.elastic.co/u/Alexander_Kley)\
**Post date:** [November 19, 2013, 8:19am UTC](https://discuss.elastic.co/t/best-practice-to-check-if-mapping-exists/14461/1 "2013-11-19T08:19:56Z")

</div>

Hi guys,

if I'll check mapping exists, i can do this in many ways, right?

First:  
esClient.admin().cluster().prepareState().setFilterIndices(index.toLowerCase()).get().getState().getMetaData().index(index).mapping(type.toLowerCase();

Second:  
esClient.admin().indices().exists(new  
IndicesExistsRequest(index.toLowerCase(),  
type.toLowerCase())).actionGet().isExists();

Third:  
esClient.admin().indices().typesExists(new TypesExistsRequest(new String[]  
{ index }, type)).actionGet().isExists();

But which is the best approach?

Best regards!  
Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [November 19, 2013, 8:35am UTC](https://discuss.elastic.co/t/best-practice-to-check-if-mapping-exists/14461/2 "2013-11-19T08:35:35Z")

</div>

Preferable is client.admin().indices().typesExists(typesExistsRequest,  
action) and checking for isExists() in the response.

See also  
org.elasticsearch.rest.action.indices.exists.types.RestTypesExistsAction

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2017, 2:06am UTC](https://discuss.elastic.co/t/best-practice-to-check-if-mapping-exists/14461/3 "2017-07-06T02:06:17Z")

</div>


