# How to grab a count of document fields and creating a percentage of fields filled in

**URL:** <https://discuss.elastic.co/t/how-to-grab-a-count-of-document-fields-and-creating-a-percentage-of-fields-filled-in/59465>\
**Category:** Elasticsearch\
**Created:** [August 31, 2016, 8:55pm UTC](https://discuss.elastic.co/t/how-to-grab-a-count-of-document-fields-and-creating-a-percentage-of-fields-filled-in/59465 "2016-08-31T20:55:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdicken73](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@tdicken73](https://discuss.elastic.co/u/tdicken73)\
**Post date:** [August 31, 2016, 8:55pm UTC](https://discuss.elastic.co/t/how-to-grab-a-count-of-document-fields-and-creating-a-percentage-of-fields-filled-in/59465/1 "2016-08-31T20:55:13Z")

</div>

Hey all,

I'm trying to find a way to see which documents are the most populated in an index. I have a dataset that is sparsely populated, some fields have empty strings or null values. I would like to create a "percentage filled" for each document and store it in a field at the end of the document. So if a document has 10 fields and only 5 were not null or empty, that document would be 50% filled and then if possible, I'd like to store that percentage in an 11th field.

Is there any metadata functionality like this built into elasticsearch?

I was looking at using the [\_size](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-size-field.html) field but that is only at the source level, not the document level. Thanks in advance for any input.

---

<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 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/how-to-grab-a-count-of-document-fields-and-creating-a-percentage-of-fields-filled-in/59465/2 "2017-07-05T22:23:28Z")

</div>


