# Calculate top common fields for matched documents

**URL:** <https://discuss.elastic.co/t/calculate-top-common-fields-for-matched-documents/25546>\
**Category:** Elasticsearch\
**Created:** [July 14, 2015, 6:35pm UTC](https://discuss.elastic.co/t/calculate-top-common-fields-for-matched-documents/25546 "2015-07-14T18:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![linlma](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@linlma](https://discuss.elastic.co/u/linlma)\
**Post date:** [July 14, 2015, 6:35pm UTC](https://discuss.elastic.co/t/calculate-top-common-fields-for-matched-documents/25546/1 "2015-07-14T18:35:25Z")

</div>

Hello Elastic Search experts,

I want to calculate top common fields, and their values for matched documents for a query, other than return the matched document itself. I want to calculate top common fields by a customized function (could be implemented by Java/Python or Scala).

The question is, is it possible to plug-in the customized function inside ElasticSearch cluster? Which has the benefit of saving bandwidth to transfer all documents back (which is huge number), v.s. only return top common fields (which size is much smaller).

If doable, any samples are appreciated.

thanks in advance,  
Lin

---

<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, 12:01am UTC](https://discuss.elastic.co/t/calculate-top-common-fields-for-matched-documents/25546/2 "2017-07-06T00:01:31Z")

</div>


