# Facet\_filter and document query return different values.?

**URL:** <https://discuss.elastic.co/t/facet-filter-and-document-query-return-different-values/14845>\
**Category:** Elasticsearch\
**Created:** [December 12, 2013, 9:54pm UTC](https://discuss.elastic.co/t/facet-filter-and-document-query-return-different-values/14845 "2013-12-12T21:54:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)\
**Post date:** [December 12, 2013, 9:54pm UTC](https://discuss.elastic.co/t/facet-filter-and-document-query-return-different-values/14845/1 "2013-12-12T21:54:03Z")

</div>

Hi,  
I have a facet\_filter query that returns facet values. When I use one in a  
document query, I get different # of results.

Here is the facet query to get the counts and terms.

_{'query': {'term': {'text': 'government'}}, 'facets': {'people':  
{'facet\_filter': {'bool': {'must': [{'term': {'people': 'military'}}]}},  
'terms': {'field': 'people'}}}, 'fields': ['id']}_

Returns facet "people" with "international" term with count 52.

When attempting to query for those 52 documents (by adding the term to the  
previous query), 61 results are returned from query not 52.

_{"filter":{"bool":{"must":[{"term":{"people":"military"}},{"term":{"people":"international"}}]}},"query":{"term":{"text":"government"}}}_

What am I missing here?

--  
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/2d978bd2-b1b9-427e-94e3-9e6a6e3d7de7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2d978bd2-b1b9-427e-94e3-9e6a6e3d7de7%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 13, 2013, 3:16pm UTC](https://discuss.elastic.co/t/facet-filter-and-document-query-return-different-values/14845/2 "2013-12-13T15:16:18Z")

</div>

Hey,

maybe the shard\_size parameter (and the explanation why it exists) may help  
you understand this problem:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--Alex

On Thu, Dec 12, 2013 at 10:54 PM, project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com) wrote:

> Hi,  
> I have a facet\_filter query that returns facet values. When I use one in  
> a document query, I get different # of results.
> 
> Here is the facet query to get the counts and terms.
> 
> _{'query': {'term': {'text': 'government'}}, 'facets': {'people':  
> {'facet\_filter': {'bool': {'must': [{'term': {'people': 'military'}}]}},  
> 'terms': {'field': 'people'}}}, 'fields': ['id']}_
> 
> Returns facet "people" with "international" term with count 52.
> 
> When attempting to query for those 52 documents (by adding the term to the  
> previous query), 61 results are returned from query not 52.
> 
> _{"filter":{"bool":{"must":[{"term":{"people":"military"}},{"term":{"people":"international"}}]}},"query":{"term":{"text":"government"}}}_
> 
> What am I missing here?
> 
> --  
> 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/2d978bd2-b1b9-427e-94e3-9e6a6e3d7de7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2d978bd2-b1b9-427e-94e3-9e6a6e3d7de7%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CAGCwEM\_EFj17cohUuyQsnbP%2BBY\_r\_2XZ4sRmNfqnSW2GcwhOFg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_EFj17cohUuyQsnbP%2BBY_r_2XZ4sRmNfqnSW2GcwhOFg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:01am UTC](https://discuss.elastic.co/t/facet-filter-and-document-query-return-different-values/14845/3 "2017-07-06T02:01:20Z")

</div>


