# Hits vs getTotalHits

**URL:** https://discuss.elastic.co/t/hits-vs-gettotalhits/19294
**Category:** Elasticsearch
**Created:** [August 14, 2014, 6:46pm UTC](https://discuss.elastic.co/t/hits-vs-gettotalhits/19294 "2014-08-14T18:46:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AsyncAwait](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asyncawait/32/1346_2.png) [@AsyncAwait](https://discuss.elastic.co/u/AsyncAwait)
#### Post date: [August 14, 2014, 6:46pm UTC](https://discuss.elastic.co/t/hits-vs-gettotalhits/19294/1 "2014-08-14T18:46:43Z")

</div>

[https://www.evernote.com/shard/s381/sh/79afa662-059a-4c1b-9337-38cf0bd0fcb5/cf9472d78647e00e8470586442d598b1/deep/0/SearchHits.java----Maven--org.elasticsearch-elasticsearch-1.2.2----exzeo-spock------Projects-exzeo-spock-.png](https://www.evernote.com/shard/s381/sh/79afa662-059a-4c1b-9337-38cf0bd0fcb5/cf9472d78647e00e8470586442d598b1/deep/0/SearchHits.java----Maven--org.elasticsearch-elasticsearch-1.2.2----exzeo-spock------Projects-exzeo-spock-.png)

Is this is for backward compatibility? Which is latest one?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d8f83077-d220-43dd-acbb-c4253ee3c1ee%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d8f83077-d220-43dd-acbb-c4253ee3c1ee%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 14, 2014, 8:35pm UTC](https://discuss.elastic.co/t/hits-vs-gettotalhits/19294/2 "2014-08-14T20:35:14Z")

</div>

IIRC, totalHits() was the first form. But some frameworks needed accessors using get/set.  
So get was added.

I would use get/set.

Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 14 août 2014 à 20:46, AsyncAwait [vadivtk@gmail.com](mailto:vadivtk@gmail.com) a écrit :
> 
> ## Is this is for backward compatibility? Which is latest one?
> 
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d8f83077-d220-43dd-acbb-c4253ee3c1ee%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d8f83077-d220-43dd-acbb-c4253ee3c1ee%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/C4C7C738-8671-413D-88A1-946109CF18F2%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/C4C7C738-8671-413D-88A1-946109CF18F2%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:08am UTC](https://discuss.elastic.co/t/hits-vs-gettotalhits/19294/3 "2017-07-06T01:08:24Z")

</div>


