# What apis should be userd to calculate the total of a field in some documents in ElasticSearch?

**URL:** <https://discuss.elastic.co/t/what-apis-should-be-userd-to-calculate-the-total-of-a-field-in-some-documents-in-elasticsearch/9413>\
**Category:** Elasticsearch\
**Created:** [October 18, 2012, 4:40pm UTC](https://discuss.elastic.co/t/what-apis-should-be-userd-to-calculate-the-total-of-a-field-in-some-documents-in-elasticsearch/9413 "2012-10-18T16:40:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![colex](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@colex](https://discuss.elastic.co/u/colex)\
**Post date:** [October 18, 2012, 4:40pm UTC](https://discuss.elastic.co/t/what-apis-should-be-userd-to-calculate-the-total-of-a-field-in-some-documents-in-elasticsearch/9413/1 "2012-10-18T16:40:29Z")

</div>

Now I have some documents in ElasticSearch like this:  
{"books":[{"name":"book1" , "price":14} , {"name":"book2" , "price":14}]}

{"books":[{"name":"book3" , "price":14} , {"name":"book4" , "price":12}]}

...  
There are 3 books whose price is 14.  
I tried "term" , but I can only get 2 , it is the total of the docments which have {"price":14}  
I don't know how to accomplish it with ES..

---

<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:08am UTC](https://discuss.elastic.co/t/what-apis-should-be-userd-to-calculate-the-total-of-a-field-in-some-documents-in-elasticsearch/9413/2 "2017-07-06T03:08:03Z")

</div>


