# How to get current count of number of fields?

**URL:** <https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542>\
**Category:** Elasticsearch\
**Created:** [April 6, 2017, 9:47pm UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542 "2017-04-06T21:47:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![billnbell](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@billnbell](https://discuss.elastic.co/u/billnbell)\
**Post date:** [April 6, 2017, 9:47pm UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542/1 "2017-04-06T21:47:03Z")

</div>

We have a lot of fields, since we prepend the typeId to the Field in order to avoid the issue with field types overlapping...

How do I do a simple query to get the # of fields in the index?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 7, 2017, 5:45am UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542/2 "2017-04-07T05:45:05Z")

</div>

I don't think there is any API that gives this as a simple number, but you may be able to use the [field stats API](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-field-stats.html) to get it.

---

<div class="post-metadata">

**Author:** ![billnbell](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@billnbell](https://discuss.elastic.co/u/billnbell)\
**Post date:** [April 11, 2017, 9:24pm UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542/3 "2017-04-11T21:24:54Z")

</div>

I cannot figure out how to do it with the field stats.

I can write Java code to do it, so if there is a way to do it with Java that would be awesome.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 12, 2017, 4:36am UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542/4 "2017-04-12T04:36:13Z")

</div>

I am not sure whether it is possible of not, so you may need to retrieve the index mapping and analyse this. As we now do have a limit on the number of fields in an index it would be useful to be able to get this information easily.

---

<div class="post-metadata">

**Author:** ![billnbell](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@billnbell](https://discuss.elastic.co/u/billnbell)\
**Post date:** [April 12, 2017, 5:00am UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542/5 "2017-04-12T05:00:54Z")

</div>

Exactly someone should make an easier way to get this info!! Please.!!

---

<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:** [May 10, 2017, 5:05am UTC](https://discuss.elastic.co/t/how-to-get-current-count-of-number-of-fields/81542/6 "2017-05-10T05:05:43Z")

</div>

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