# Way to get all Index Types for Index

**URL:** <https://discuss.elastic.co/t/way-to-get-all-index-types-for-index/6146>\
**Category:** Elasticsearch\
**Created:** [December 13, 2011, 5:49pm UTC](https://discuss.elastic.co/t/way-to-get-all-index-types-for-index/6146 "2011-12-13T17:49:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Padilla](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Padilla](https://discuss.elastic.co/u/Nicholas_Padilla)\
**Post date:** [December 13, 2011, 5:49pm UTC](https://discuss.elastic.co/t/way-to-get-all-index-types-for-index/6146/1 "2011-12-13T17:49:11Z")

</div>

Hello!

I am working on integrating ES into a java application that takes  
generic json and indexing it for search. The json represents  
different forms that users interact with and follow a uniform keys  
pattern, so will make searching over data an easy task. However, the  
actual schema will be different per form and since ES can work schema-  
less I decided to use ES. I have already got the data indexed and am  
running searches over that data. I want to create some search forms  
dynamically based on the Index Type, I am creating many index types  
per index - basically one index type per form.

So having said all that, I would like to get all index types for an  
index. I can then query one record for each index type and get all  
fields for the type to build the Search Form. I want the app to  
remain schema-less so we can handle all forms they decide to build in  
the future. Any ideas or tips/hints that can point me in the right  
direction. I have looked at the java api and queried the forums about  
this topic but haven't found anything that would do what I am looking  
for.

My only idea at this point would be to index the json schema in a  
separate index. I would get the schema by parsing the json when  
indexing, then add the fields to the index typed again on the form.  
This way I can always easily get at the form fields. If this is the  
only way to do what I am looking for then I can take that approach.  
However, I would like to see if there are any more graceful ways of  
handling this scenario.

Thanks for the help, and reading this far!

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 13, 2011, 10:39pm UTC](https://discuss.elastic.co/t/way-to-get-all-index-types-for-index/6146/2 "2011-12-13T22:39:54Z")

</div>

Use the get mapping API when you use REST, or the cluster state API when  
you use the Java API (here is how it is used in the REST get mapping  
endpoint:  
[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java#L66](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java#L66)  
.

On Tue, Dec 13, 2011 at 7:49 PM, Nicholas Padilla \<  
[nicholas@monstersoftwarellc.com](mailto:nicholas@monstersoftwarellc.com)\> wrote:

> Hello!
> 
> I am working on integrating ES into a java application that takes  
> generic json and indexing it for search. The json represents  
> different forms that users interact with and follow a uniform keys  
> pattern, so will make searching over data an easy task. However, the  
> actual schema will be different per form and since ES can work schema-  
> less I decided to use ES. I have already got the data indexed and am  
> running searches over that data. I want to create some search forms  
> dynamically based on the Index Type, I am creating many index types  
> per index - basically one index type per form.
> 
> So having said all that, I would like to get all index types for an  
> index. I can then query one record for each index type and get all  
> fields for the type to build the Search Form. I want the app to  
> remain schema-less so we can handle all forms they decide to build in  
> the future. Any ideas or tips/hints that can point me in the right  
> direction. I have looked at the java api and queried the forums about  
> this topic but haven't found anything that would do what I am looking  
> for.
> 
> My only idea at this point would be to index the json schema in a  
> separate index. I would get the schema by parsing the json when  
> indexing, then add the fields to the index typed again on the form.  
> This way I can always easily get at the form fields. If this is the  
> only way to do what I am looking for then I can take that approach.  
> However, I would like to see if there are any more graceful ways of  
> handling this scenario.
> 
> Thanks for the help, and reading this far!

---

<div class="post-metadata">

**Author:** ![Nicholas\_Padilla](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Padilla](https://discuss.elastic.co/u/Nicholas_Padilla)\
**Post date:** [December 14, 2011, 7:44am UTC](https://discuss.elastic.co/t/way-to-get-all-index-types-for-index/6146/3 "2011-12-14T07:44:21Z")

</div>

Hey Shay,

That worked like a charm!

Thanks for your time!

On Dec 13, 3:39 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Use the get mapping API when you use REST, or the cluster state API when  
> you use the Java API (here is how it is used in the REST get mapping  
> endpoint:[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j)...  
> .
> 
> On Tue, Dec 13, 2011 at 7:49 PM, Nicholas Padilla \<
> 
> [nicho...@monstersoftwarellc.com](mailto:nicho...@monstersoftwarellc.com)\> wrote:
> 
> > Hello!
> 
> > I am working on integrating ES into a java application that takes  
> > generic json and indexing it for search. The json represents  
> > different forms that users interact with and follow a uniform keys  
> > pattern, so will make searching over data an easy task. However, the  
> > actual schema will be different per form and since ES can work schema-  
> > less I decided to use ES. I have already got the data indexed and am  
> > running searches over that data. I want to create some search forms  
> > dynamically based on the Index Type, I am creating many index types  
> > per index - basically one index type per form.
> 
> > So having said all that, I would like to get all index types for an  
> > index. I can then query one record for each index type and get all  
> > fields for the type to build the Search Form. I want the app to  
> > remain schema-less so we can handle all forms they decide to build in  
> > the future. Any ideas or tips/hints that can point me in the right  
> > direction. I have looked at the java api and queried the forums about  
> > this topic but haven't found anything that would do what I am looking  
> > for.
> 
> > My only idea at this point would be to index the json schema in a  
> > separate index. I would get the schema by parsing the json when  
> > indexing, then add the fields to the index typed again on the form.  
> > This way I can always easily get at the form fields. If this is the  
> > only way to do what I am looking for then I can take that approach.  
> > However, I would like to see if there are any more graceful ways of  
> > handling this scenario.
> 
> > Thanks for the help, and reading this far!

---

<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:45am UTC](https://discuss.elastic.co/t/way-to-get-all-index-types-for-index/6146/4 "2017-07-06T03:45:24Z")

</div>


