# Difference in nested facet filters

**URL:** <https://discuss.elastic.co/t/difference-in-nested-facet-filters/13882>\
**Category:** Elasticsearch\
**Created:** [October 9, 2013, 12:50am UTC](https://discuss.elastic.co/t/difference-in-nested-facet-filters/13882 "2013-10-09T00:50:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 9, 2013, 12:50am UTC](https://discuss.elastic.co/t/difference-in-nested-facet-filters/13882/1 "2013-10-09T00:50:01Z")

</div>

Fine-tuning some queries and I had a question. There are two syntaxes  
(syntaxii?) that produce equivalent results:

DIRECT TERM FILTER:  
{  
"facets": {  
"nested1": {  
"nested": "nested1",  
"terms": {  
"field": "nested1.field1"  
},  
"facet\_filter": {  
"term": {  
"nested1.field2": 1  
}  
}  
}  
}  
}

NESTED FILTER:  
{  
"facets": {  
"nested1": {  
"nested": "nested1",  
"terms": {  
"field": "nested1.field1"  
},  
"facet\_filter": {  
"nested": {  
"path": "nested1",  
"join": false,  
"query": {  
"term": {  
"nested1.field2": 1  
}  
}  
}  
}  
}  
}  
}

Obviously, the first one is far more concise. Not sure what are the caching  
difference would be since the latter has explicit caching. My only guess  
is the latter is used when combining filters based on fields in both the  
nested document and the parent. Correct?

Cheers,

Ivan

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 11, 2013, 7:39pm UTC](https://discuss.elastic.co/t/difference-in-nested-facet-filters/13882/2 "2013-10-11T19:39:19Z")

</div>

When does the default join (true) make sense? I cannot come up with use  
case where facets work with the default join.

--  
Ivan

On Tue, Oct 8, 2013 at 5:50 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> Fine-tuning some queries and I had a question. There are two syntaxes  
> (syntaxii?) that produce equivalent results:
> 
> DIRECT TERM FILTER:  
> {  
> "facets": {  
> "nested1": {  
> "nested": "nested1",  
> "terms": {  
> "field": "nested1.field1"  
> },  
> "facet\_filter": {  
> "term": {  
> "nested1.field2": 1  
> }  
> }  
> }  
> }  
> }
> 
> NESTED FILTER:  
> {  
> "facets": {  
> "nested1": {  
> "nested": "nested1",  
> "terms": {  
> "field": "nested1.field1"  
> },  
> "facet\_filter": {  
> "nested": {  
> "path": "nested1",  
> "join": false,  
> "query": {  
> "term": {  
> "nested1.field2": 1  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> Obviously, the first one is far more concise. Not sure what are the  
> caching difference would be since the latter has explicit caching. My only  
> guess is the latter is used when combining filters based on fields in both  
> the nested document and the parent. Correct?
> 
> Cheers,
> 
> Ivan

--  
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).  
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:12am UTC](https://discuss.elastic.co/t/difference-in-nested-facet-filters/13882/3 "2017-07-06T02:12:48Z")

</div>


