# Empty terms for Terms Filter in 0.21

**URL:** <https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592>\
**Category:** Elasticsearch\
**Created:** [February 1, 2013, 4:04pm UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592 "2013-02-01T16:04:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel\_Mlynarczyk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_mlynarczyk/32/1568_2.png) [@Pawel\_Mlynarczyk](https://discuss.elastic.co/u/Pawel_Mlynarczyk)\
**Post date:** [February 1, 2013, 4:04pm UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/1 "2013-02-01T16:04:34Z")

</div>

Hello,

I've been trying out the new beta version of ES and I've got a question.

Version 0.19.x allowed us to provide an empty set of Terms for Terms Filter:

{  
"constant\_score" : {  
"filter" : {  
"terms" : { "user" : []}  
}  
}  
}

and now, in 0.21 it is forbidden, ES throws IllegalArgumentException[no  
terms provided].

Is that intended?

Regards,  
Paweł Młynarczyk

--  
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:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [February 2, 2013, 2:07am UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/2 "2013-02-02T02:07:59Z")

</div>

Yes, it's result of this  
change: [[LUCENE-4511] TermsFilter might return wrong results if a field is not indexed or not present in the index - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4511)

On Friday, February 1, 2013 11:04:34 AM UTC-5, Paweł Młynarczyk wrote:

> Hello,
> 
> I've been trying out the new beta version of ES and I've got a question.
> 
> Version 0.19.x allowed us to provide an empty set of Terms for Terms  
> Filter:
> 
> {  
> "constant\_score" : {  
> "filter" : {  
> "terms" : { "user" : }  
> }  
> }  
> }
> 
> and now, in 0.21 it is forbidden, ES throws IllegalArgumentException[no  
> terms provided].
> 
> Is that intended?
> 
> Regards,  
> Paweł Młynarczyk

--  
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:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 2, 2013, 10:07pm UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/3 "2013-02-02T22:07:37Z")

</div>

What do you expect when providing an empty array, do you mean to find documents that have no values for user? We have the missing filter for it, but we could identify an empty array and automatically do a "missing" filter in that case.

On Feb 1, 2013, at 5:04 PM, Paweł Młynarczyk [zwarios@gmail.com](mailto:zwarios@gmail.com) wrote:

> Hello,
> 
> I've been trying out the new beta version of ES and I've got a question.
> 
> Version 0.19.x allowed us to provide an empty set of Terms for Terms Filter:
> 
> {  
> "constant\_score" : {  
> "filter" : {  
> "terms" : { "user" : }  
> }  
> }  
> }
> 
> and now, in 0.21 it is forbidden, ES throws IllegalArgumentException[no terms provided].
> 
> Is that intended?
> 
> Regards,  
> Paweł Młynarczyk
> 
> --  
> 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).

--  
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:** ![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:** [February 4, 2013, 9:15am UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/4 "2013-02-04T09:15:51Z")

</div>

I created a Pull Request here: [When termsFilter is empty, use missingFilter instead by dadoonet · Pull Request #2613 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/2613)

David.

Le 2 févr. 2013 à 23:07, [kimchy@gmail.com](mailto:kimchy@gmail.com) a écrit :

> What do you expect when providing an empty array, do you mean to find documents that have no values for user? We have the missing filter for it, but we could identify an empty array and automatically do a "missing" filter in that case.
> 
> On Feb 1, 2013, at 5:04 PM, Paweł Młynarczyk [zwarios@gmail.com](mailto:zwarios@gmail.com) wrote:
> 
> > Hello,
> > 
> > I've been trying out the new beta version of ES and I've got a question.
> > 
> > Version 0.19.x allowed us to provide an empty set of Terms for Terms Filter:
> > 
> > {  
> > "constant\_score" : {  
> > "filter" : {  
> > "terms" : { "user" : }  
> > }  
> > }  
> > }
> > 
> > and now, in 0.21 it is forbidden, ES throws IllegalArgumentException[no terms provided].
> > 
> > Is that intended?
> > 
> > Regards,  
> > Paweł Młynarczyk
> > 
> > --  
> > 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).
> 
> --  
> 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).

--  
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:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [February 4, 2013, 10:40am UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/5 "2013-02-04T10:40:22Z")

</div>

I think that using missingFilter when termsFilter has empty terms list is  
misleading.  
I understand termsFilter like: return only those documents, where a field  
has one of the values provided as terms.  
So empty terms list in termsFilter == doesn't return anything ==  
notFilter(matchAllFilter()).  
Also notFilter(termsFilter with empty terms list) == matchAllFilter.

I use this behaviour of ES 0.19 to exclude some documents from results:  
notFilter(termsFilter("documentType", ))  
If is empty then all documents should be  
returned.

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 4, 2013, 10:56am UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/6 "2013-02-04T10:56:09Z")

</div>

On Mon, 2013-02-04 at 02:40 -0800, Wojciech Durczyński wrote:

> I think that using missingFilter when termsFilter has empty terms list  
> is misleading.

I agree.

> I understand termsFilter like: return only those documents, where a  
> field has one of the values provided as terms.  
> So empty terms list in termsFilter == doesn't return anything ==  
> notFilter(matchAllFilter()).  
> Also notFilter(termsFilter with empty terms list) == matchAllFilter.

I understand it differently. Giving that you are filtering documents, a  
filter with no terms for me means: don't filter on anything, so give me  
all docs, ie match\_all

clint

--  
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:53am UTC](https://discuss.elastic.co/t/empty-terms-for-terms-filter-in-0-21/10592/7 "2017-07-06T02:53:08Z")

</div>


