# How many index type exist in given index using java API?

**URL:** <https://discuss.elastic.co/t/how-many-index-type-exist-in-given-index-using-java-api/7458>\
**Category:** Elasticsearch\
**Created:** [April 25, 2012, 6:27am UTC](https://discuss.elastic.co/t/how-many-index-type-exist-in-given-index-using-java-api/7458 "2012-04-25T06:27:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_4](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@Sam\_4](https://discuss.elastic.co/u/Sam_4)\
**Post date:** [April 25, 2012, 6:27am UTC](https://discuss.elastic.co/t/how-many-index-type-exist-in-given-index-using-java-api/7458/1 "2012-04-25T06:27:47Z")

</div>

Hi

I have one index and multiple index type, I want to know whether index  
type is available or not index,also how can i get the list of all  
available index type list.

Thanks

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 25, 2012, 7:13am UTC](https://discuss.elastic.co/t/how-many-index-type-exist-in-given-index-using-java-api/7458/2 "2012-04-25T07:13:17Z")

</div>

You can get the list of all available types for an index using Get Mapping  
API[http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping.html](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping.html)  
.

On Wednesday, April 25, 2012 2:27:47 AM UTC-4, sam wrote:

> Hi
> 
> I have one index and multiple index type, I want to know whether index  
> type is available or not index,also how can i get the list of all  
> available index type list.
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![Sam\_4](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@Sam\_4](https://discuss.elastic.co/u/Sam_4)\
**Post date:** [April 25, 2012, 7:55am UTC](https://discuss.elastic.co/t/how-many-index-type-exist-in-given-index-using-java-api/7458/3 "2012-04-25T07:55:54Z")

</div>

Thanks fro reply.i have following code to get the all available list :

ClusterStateResponse clusterResponse =  
client.admin().cluster().prepareState().execute().actionGet();  
ImmutableMap\<String, MappingMetaData\> mappings =  
clusterResponse.state().getMetaData().index(indexName).getMappings();  
boolean containsKey = mappings.containsKey(indexType);

On Wednesday, April 25, 2012 12:43:17 PM UTC+5:30, Igor Motov wrote:

> You can get the list of all available types for an index using Get  
> Mapping API[http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping.html](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping.html)  
> .
> 
> On Wednesday, April 25, 2012 2:27:47 AM UTC-4, sam wrote:
> 
> > Hi
> > 
> > I have one index and multiple index type, I want to know whether index  
> > type is available or not index,also how can i get the list of all  
> > available index type list.
> > 
> > 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:** [July 6, 2017, 3:31am UTC](https://discuss.elastic.co/t/how-many-index-type-exist-in-given-index-using-java-api/7458/4 "2017-07-06T03:31:13Z")

</div>


