# Re: Search response hits vs Facet count

**URL:** <https://discuss.elastic.co/t/re-search-response-hits-vs-facet-count/9025>\
**Category:** Elasticsearch\
**Created:** [September 14, 2012, 3:38pm UTC](https://discuss.elastic.co/t/re-search-response-hits-vs-facet-count/9025 "2012-09-14T15:38:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)\
**Post date:** [September 14, 2012, 3:38pm UTC](https://discuss.elastic.co/t/re-search-response-hits-vs-facet-count/9025/1 "2012-09-14T15:38:14Z")

</div>

On 9/6/2012 7:35 AM, Dirk wrote:

> Hi,
> 
> Regarding facet usage, is there any reason for doing the below:
> 
> {"query": {  
> "filtered" : {  
> "filter" : {  
> "term" : { "myField" : "myValue" }  
> },  
> "query" : { "match\_all" : {} }  
> }  
> },  
> "facets" : {  
> "my\_facet" : {  
> "filter" : {  
> "term" : { "myField" : "myValue" }  
> }  
> }  
> },  
> "from":0,  
> "size":20  
> }'
> 
> Can I not simply use the SearchResponse.hits.totalHits() count as this  
> would be same as the facet count in this case?
> 
> Kind Regards,
> 
> ## Dirk

totalHits is the number of documents, but I think if "myField" is  
tokenized/analyzed won't the facet total include the total number of  
occurrences of the field?  
I'd try a simple example to test the idea.

-Paul

--

---

<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:12am UTC](https://discuss.elastic.co/t/re-search-response-hits-vs-facet-count/9025/2 "2017-07-06T03:12:43Z")

</div>


