# Queries, filters and match\_all

**URL:** <https://discuss.elastic.co/t/queries-filters-and-match-all/17884>\
**Category:** Elasticsearch\
**Created:** [June 3, 2014, 12:27pm UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884 "2014-06-03T12:27:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zabazhanov\_Arkady](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zabazhanov_arkady/32/1495_2.png) [@Zabazhanov\_Arkady](https://discuss.elastic.co/u/Zabazhanov_Arkady)\
**Post date:** [June 3, 2014, 12:27pm UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/1 "2014-06-03T12:27:17Z")

</div>

Hello. Help me please, I'm confused. As far as I remember, there was the  
only way to pass filters to search query - via filtered query. But  
currently there is a top-level filter part of the query. However, top-level  
filter affects query only and doesn't affect i.e. facets. But filtered  
query filter affects both of the query and facets facilities. Also, I  
remember there was a time I need to add match\_all query to filtered query section  
if query was empty and filters only was present. Otherwise returned empty  
set of documents. Since I'm trying to create high-level Ruby library could  
you please answer following questions:

1. Which way is preferred now and in future: filtered top-level query or  
top-level filter with top-level query?
2. How do you plan to resolve such an API inconsistency when filtered query  
filter affects outside statements and top-level filter doesn't affect some  
parts of request?
3. Why do I remember about match\_all feature and when did requests started  
to return all the documents with empty query section in filtered query? I'm  
checking it right now on 1.2.0 and I don't need to use match\_all, or  
constant\_score it just returns all the docs for me.

Thanks in advance.

--  
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/1325caa9-cd4b-492e-a443-f4b63f99c104%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1325caa9-cd4b-492e-a443-f4b63f99c104%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Zabazhanov\_Arkady](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zabazhanov_arkady/32/1495_2.png) [@Zabazhanov\_Arkady](https://discuss.elastic.co/u/Zabazhanov_Arkady)\
**Post date:** [June 4, 2014, 3:11am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/2 "2014-06-04T03:11:44Z")

</div>

Btw, Answer for the second question is top-level filter was renamed to  
post\_filter. That's awesome. So the first question is answered too.  
Filtered query is preferred.  
Still waiting for an answer for the third question. Since I didn't find  
filter to post\_filter renaming in changelog  
([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find anything  
about new query behavior. I need just version where was it changed, please.

вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy Zabazhanov  
написал:

> Hello. Help me please, I'm confused. As far as I remember, there was the  
> only way to pass filters to search query - via filtered query. But  
> currently there is a top-level filter part of the query. However,  
> top-level filter affects query only and doesn't affect i.e. facets. But  
> filtered query filter affects both of the query and facets facilities.  
> Also, I remember there was a time I need to add match\_all query to  
> filtered query section if query was empty and filters only was present.  
> Otherwise returned empty set of documents. Since I'm trying to create  
> high-level Ruby library could you please answer following questions:
> 
> 1. Which way is preferred now and in future: filtered top-level query or  
> top-level filter with top-level query?
> 2. How do you plan to resolve such an API inconsistency when filtered  
> query filter affects outside statements and top-level filter doesn't affect  
> some parts of request?
> 3. Why do I remember about match\_all feature and when did requests  
> started to return all the documents with empty query section in filtered  
> query? I'm checking it right now on 1.2.0 and I don't need to use  
> match\_all, or constant\_score it just returns all the docs for me.
> 
> Thanks in advance.

--  
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/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [June 4, 2014, 11:20pm UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/3 "2014-06-04T23:20:56Z")

</div>

There is no label, but the change was made last December:

> <https://github.com/elastic/elasticsearch/pull/4461>

It appears that the REST API still supports the old notation, but the  
change did break Java backwards compatibility

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71)

--  
Ivan

On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov [kinwizard@gmail.com](mailto:kinwizard@gmail.com)  
wrote:

> Btw, Answer for the second question is top-level filter was renamed to  
> post\_filter. That's awesome. So the first question is answered too.  
> Filtered query is preferred.  
> Still waiting for an answer for the third question. Since I didn't find  
> filter to post\_filter renaming in changelog (  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find anything  
> about new query behavior. I need just version where was it changed, please.
> 
> вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy Zabazhanov  
> написал:
> 
> > Hello. Help me please, I'm confused. As far as I remember, there was the  
> > only way to pass filters to search query - via filtered query. But  
> > currently there is a top-level filter part of the query. However,  
> > top-level filter affects query only and doesn't affect i.e. facets. But  
> > filtered query filter affects both of the query and facets facilities.  
> > Also, I remember there was a time I need to add match\_all query to  
> > filtered query section if query was empty and filters only was present.  
> > Otherwise returned empty set of documents. Since I'm trying to create  
> > high-level Ruby library could you please answer following questions:
> > 
> > 1. Which way is preferred now and in future: filtered top-level query or  
> > top-level filter with top-level query?
> > 2. How do you plan to resolve such an API inconsistency when filtered  
> > query filter affects outside statements and top-level filter doesn't affect  
> > some parts of request?
> > 3. Why do I remember about match\_all feature and when did requests  
> > started to return all the documents with empty query section in filtered  
> > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > match\_all, or constant\_score it just returns all the docs for me.
> > 
> > Thanks in advance.
> 
> --  
> 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/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> 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/CALY%3DcQB7xiafarYujtzg14EpTTi709DJjgZ%3DwyJb8J1tcwFo6A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQB7xiafarYujtzg14EpTTi709DJjgZ%3DwyJb8J1tcwFo6A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Zabazhanov\_Arkady](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zabazhanov_arkady/32/1495_2.png) [@Zabazhanov\_Arkady](https://discuss.elastic.co/u/Zabazhanov_Arkady)\
**Post date:** [June 6, 2014, 12:14am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/4 "2014-06-06T00:14:27Z")

</div>

Yeah, I've got ehis already, thanks.

I'm still confused why filtered query is returning all results even without  
match\_all in filtered query.

четверг, 5 июня 2014 г., 6:21:03 UTC+7 пользователь Ivan Brusic написал:

> There is no label, but the change was made last December:
> 
> [Renamed top level `filter` to `post_filter`. by martijnvg · Pull Request #4461 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4461)
> 
> It appears that the REST API still supports the old notation, but the  
> change did break Java backwards compatibility
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71)
> 
> --  
> Ivan
> 
> On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov \<[kinw...@gmail.com](mailto:kinw...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Btw, Answer for the second question is top-level filter was renamed to  
> > post\_filter. That's awesome. So the first question is answered too.  
> > Filtered query is preferred.  
> > Still waiting for an answer for the third question. Since I didn't find  
> > filter to post\_filter renaming in changelog (  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find anything  
> > about new query behavior. I need just version where was it changed, please.
> > 
> > вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy Zabazhanov  
> > написал:
> > 
> > > Hello. Help me please, I'm confused. As far as I remember, there was the  
> > > only way to pass filters to search query - via filtered query. But  
> > > currently there is a top-level filter part of the query. However,  
> > > top-level filter affects query only and doesn't affect i.e. facets. But  
> > > filtered query filter affects both of the query and facets facilities.  
> > > Also, I remember there was a time I need to add match\_all query to  
> > > filtered query section if query was empty and filters only was present.  
> > > Otherwise returned empty set of documents. Since I'm trying to create  
> > > high-level Ruby library could you please answer following questions:
> > > 
> > > 1. Which way is preferred now and in future: filtered top-level query or  
> > > top-level filter with top-level query?
> > > 2. How do you plan to resolve such an API inconsistency when filtered  
> > > query filter affects outside statements and top-level filter doesn't affect  
> > > some parts of request?
> > > 3. Why do I remember about match\_all feature and when did requests  
> > > started to return all the documents with empty query section in filtered  
> > > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > > match\_all, or constant\_score it just returns all the docs for me.
> > > 
> > > Thanks in advance.
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > 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/c69f1fa3-dc85-47a9-bdee-570873f78f76%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c69f1fa3-dc85-47a9-bdee-570873f78f76%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Zabazhanov\_Arkady](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zabazhanov_arkady/32/1495_2.png) [@Zabazhanov\_Arkady](https://discuss.elastic.co/u/Zabazhanov_Arkady)\
**Post date:** [June 9, 2014, 4:34am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/5 "2014-06-09T04:34:25Z")

</div>

Guys, I still need help, A've tried to change filtered query strategies. It  
returns all the filtered results anyway for versions 1.0.0 - 1.2.1. When  
this behavior was changed and how? Why don't I need match\_all for filtered  
query with empty query?

пятница, 6 июня 2014 г., 7:14:28 UTC+7 пользователь Arkadiy Zabazhanov  
написал:

> Yeah, I've got ehis already, thanks.
> 
> I'm still confused why filtered query is returning all results even  
> without match\_all in filtered query.
> 
> четверг, 5 июня 2014 г., 6:21:03 UTC+7 пользователь Ivan Brusic написал:
> 
> > There is no label, but the change was made last December:
> > 
> > [Renamed top level `filter` to `post_filter`. by martijnvg · Pull Request #4461 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4461)
> > 
> > It appears that the REST API still supports the old notation, but the  
> > change did break Java backwards compatibility
> > 
> > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71)
> > 
> > --  
> > Ivan
> > 
> > On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov [kinw...@gmail.com](mailto:kinw...@gmail.com)  
> > wrote:
> > 
> > > Btw, Answer for the second question is top-level filter was renamed to  
> > > post\_filter. That's awesome. So the first question is answered too.  
> > > Filtered query is preferred.  
> > > Still waiting for an answer for the third question. Since I didn't find  
> > > filter to post\_filter renaming in changelog (  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find  
> > > anything about new query behavior. I need just version where was it  
> > > changed, please.
> > > 
> > > вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy Zabazhanov  
> > > написал:
> > > 
> > > > Hello. Help me please, I'm confused. As far as I remember, there was  
> > > > the only way to pass filters to search query - via filtered query. But  
> > > > currently there is a top-level filter part of the query. However,  
> > > > top-level filter affects query only and doesn't affect i.e. facets.  
> > > > But filtered query filter affects both of the query and facets facilities.  
> > > > Also, I remember there was a time I need to add match\_all query to  
> > > > filtered query section if query was empty and filters only was  
> > > > present. Otherwise returned empty set of documents. Since I'm trying to  
> > > > create high-level Ruby library could you please answer following questions:
> > > > 
> > > > 1. Which way is preferred now and in future: filtered top-level query  
> > > > or top-level filter with top-level query?
> > > > 2. How do you plan to resolve such an API inconsistency when filtered  
> > > > query filter affects outside statements and top-level filter doesn't affect  
> > > > some parts of request?
> > > > 3. Why do I remember about match\_all feature and when did requests  
> > > > started to return all the documents with empty query section in filtered  
> > > > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > > > match\_all, or constant\_score it just returns all the docs for me.
> > > > 
> > > > Thanks in advance.
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > 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/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [June 9, 2014, 7:27am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/6 "2014-06-09T07:27:58Z")

</div>

Does it matter? From what I can tell, some code was added in 0.90

> <https://github.com/elastic/elasticsearch/commit/6687ecb038b55416d4bb37d29746e86f2624f06b>
>
> closes #2718

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java#L54](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java#L54)

--  
Ivan

On Sun, Jun 8, 2014 at 9:34 PM, Arkadiy Zabazhanov [kinwizard@gmail.com](mailto:kinwizard@gmail.com)  
wrote:

> Guys, I still need help, A've tried to change filtered query strategies.  
> It returns all the filtered results anyway for versions 1.0.0 - 1.2.1. When  
> this behavior was changed and how? Why don't I need match\_all for filtered  
> query with empty query?
> 
> пятница, 6 июня 2014 г., 7:14:28 UTC+7 пользователь Arkadiy Zabazhanov  
> написал:
> 
> > Yeah, I've got ehis already, thanks.
> > 
> > I'm still confused why filtered query is returning all results even  
> > without match\_all in filtered query.
> > 
> > четверг, 5 июня 2014 г., 6:21:03 UTC+7 пользователь Ivan Brusic написал:
> > 
> > > There is no label, but the change was made last December:
> > > 
> > > [Renamed top level `filter` to `post_filter`. by martijnvg · Pull Request #4461 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4461)
> > > 
> > > It appears that the REST API still supports the old notation, but the  
> > > change did break Java backwards compatibility
> > > 
> > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > > blob/master/src/main/java/org/elasticsearch/search/query/  
> > > QueryPhase.java#L71
> > > 
> > > --  
> > > Ivan
> > > 
> > > On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov [kinw...@gmail.com](mailto:kinw...@gmail.com)  
> > > wrote:
> > > 
> > > > Btw, Answer for the second question is top-level filter was renamed to  
> > > > post\_filter. That's awesome. So the first question is answered too.  
> > > > Filtered query is preferred.  
> > > > Still waiting for an answer for the third question. Since I didn't find  
> > > > filter to post\_filter renaming in changelog (  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find  
> > > > anything about new query behavior. I need just version where was it  
> > > > changed, please.
> > > > 
> > > > вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy Zabazhanov  
> > > > написал:
> > > > 
> > > > > Hello. Help me please, I'm confused. As far as I remember, there was  
> > > > > the only way to pass filters to search query - via filtered query. But  
> > > > > currently there is a top-level filter part of the query. However,  
> > > > > top-level filter affects query only and doesn't affect i.e. facets.  
> > > > > But filtered query filter affects both of the query and facets  
> > > > > facilities. Also, I remember there was a time I need to add match\_all query  
> > > > > to filtered query section if query was empty and filters only was  
> > > > > present. Otherwise returned empty set of documents. Since I'm trying to  
> > > > > create high-level Ruby library could you please answer following questions:
> > > > > 
> > > > > 1. Which way is preferred now and in future: filtered top-level query  
> > > > > or top-level filter with top-level query?
> > > > > 2. How do you plan to resolve such an API inconsistency when filtered  
> > > > > query filter affects outside statements and top-level filter doesn't affect  
> > > > > some parts of request?
> > > > > 3. Why do I remember about match\_all feature and when did requests  
> > > > > started to return all the documents with empty query section in filtered  
> > > > > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > > > > match\_all, or constant\_score it just returns all the docs for me.
> > > > > 
> > > > > Thanks in advance.
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > 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/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> 
> 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/CALY%3DcQCXkh\_a8TA53PXwJc92DmcxPWQa1NT%2BLsYq%2BEbYqOWGHA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCXkh_a8TA53PXwJc92DmcxPWQa1NT%2BLsYq%2BEbYqOWGHA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Zabazhanov\_Arkady](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zabazhanov_arkady/32/1495_2.png) [@Zabazhanov\_Arkady](https://discuss.elastic.co/u/Zabazhanov_Arkady)\
**Post date:** [June 9, 2014, 7:50am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/7 "2014-06-09T07:50:01Z")

</div>

Yeah, it does matter because previously I had to add match\_all to empty  
queries if I was need to get all the results in case of empty query. It  
seems currently any empty query replaces with match\_all (this follows from  
your links), so I don't need to use it explicitly anymore. Am I correct?

I just need to confirm this to remove obsolete code from my library.

понедельник, 9 июня 2014 г., 14:28:07 UTC+7 пользователь Ivan Brusic  
написал:

> Does it matter? From what I can tell, some code was added in 0.90
> 
> [Query DSL: Filtered query to make query optional (defaults to mach\_all) · elastic/elasticsearch@6687ecb · GitHub](https://github.com/elasticsearch/elasticsearch/commit/6687ecb038b55416d4bb37d29746e86f2624f06b)
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java#L54](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java#L54)
> 
> --  
> Ivan
> 
> On Sun, Jun 8, 2014 at 9:34 PM, Arkadiy Zabazhanov \<[kinw...@gmail.com](mailto:kinw...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Guys, I still need help, A've tried to change filtered query strategies.  
> > It returns all the filtered results anyway for versions 1.0.0 - 1.2.1. When  
> > this behavior was changed and how? Why don't I need match\_all for filtered  
> > query with empty query?
> > 
> > пятница, 6 июня 2014 г., 7:14:28 UTC+7 пользователь Arkadiy Zabazhanov  
> > написал:
> > 
> > > Yeah, I've got ehis already, thanks.
> > > 
> > > I'm still confused why filtered query is returning all results even  
> > > without match\_all in filtered query.
> > > 
> > > четверг, 5 июня 2014 г., 6:21:03 UTC+7 пользователь Ivan Brusic написал:
> > > 
> > > > There is no label, but the change was made last December:
> > > > 
> > > > [Renamed top level `filter` to `post_filter`. by martijnvg · Pull Request #4461 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4461)
> > > > 
> > > > It appears that the REST API still supports the old notation, but the  
> > > > change did break Java backwards compatibility
> > > > 
> > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > > > blob/master/src/main/java/org/elasticsearch/search/query/  
> > > > QueryPhase.java#L71
> > > > 
> > > > --  
> > > > Ivan
> > > > 
> > > > On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov [kinw...@gmail.com](mailto:kinw...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Btw, Answer for the second question is top-level filter was renamed to  
> > > > > post\_filter. That's awesome. So the first question is answered too.  
> > > > > Filtered query is preferred.  
> > > > > Still waiting for an answer for the third question. Since I didn't  
> > > > > find filter to post\_filter renaming in changelog (  
> > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find  
> > > > > anything about new query behavior. I need just version where was it  
> > > > > changed, please.
> > > > > 
> > > > > вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy  
> > > > > Zabazhanov написал:
> > > > > 
> > > > > > Hello. Help me please, I'm confused. As far as I remember, there was  
> > > > > > the only way to pass filters to search query - via filtered query. But  
> > > > > > currently there is a top-level filter part of the query. However,  
> > > > > > top-level filter affects query only and doesn't affect i.e. facets.  
> > > > > > But filtered query filter affects both of the query and facets  
> > > > > > facilities. Also, I remember there was a time I need to add match\_all query  
> > > > > > to filtered query section if query was empty and filters only was  
> > > > > > present. Otherwise returned empty set of documents. Since I'm trying to  
> > > > > > create high-level Ruby library could you please answer following questions:
> > > > > > 
> > > > > > 1. Which way is preferred now and in future: filtered top-level query  
> > > > > > or top-level filter with top-level query?
> > > > > > 2. How do you plan to resolve such an API inconsistency when filtered  
> > > > > > query filter affects outside statements and top-level filter doesn't affect  
> > > > > > some parts of request?
> > > > > > 3. Why do I remember about match\_all feature and when did requests  
> > > > > > started to return all the documents with empty query section in filtered  
> > > > > > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > > > > > match\_all, or constant\_score it just returns all the docs for me.
> > > > > > 
> > > > > > Thanks in advance.
> > > > > 
> > > > > --  
> > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%  
> > > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > > 
> > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > 
> > 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/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [June 9, 2014, 3:58pm UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/8 "2014-06-09T15:58:53Z")

</div>

I personally would not count any any default behaviors and would choose to  
use match\_all explicitly in my calls. Having some filtered queries with no  
query (default match all) and some with a more detailed query would be  
inconsistent, so my preference would be to always have a query.

It comes down to personal preference. At this point, changing the default  
behavior would be a breaking change, so I doubt the Elasticsearch team  
would ever revert, but you never know...

--  
Ivan

On Mon, Jun 9, 2014 at 12:50 AM, Arkadiy Zabazhanov [kinwizard@gmail.com](mailto:kinwizard@gmail.com)  
wrote:

> Yeah, it does matter because previously I had to add match\_all to empty  
> queries if I was need to get all the results in case of empty query. It  
> seems currently any empty query replaces with match\_all (this follows from  
> your links), so I don't need to use it explicitly anymore. Am I correct?
> 
> I just need to confirm this to remove obsolete code from my library.
> 
> понедельник, 9 июня 2014 г., 14:28:07 UTC+7 пользователь Ivan Brusic  
> написал:
> 
> > Does it matter? From what I can tell, some code was added in 0.90
> > 
> > [Add docs for the include\_named\_queries\_score param (#103155) · elastic/elasticsearch@47b5753 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/)  
> > 6687ecb038b55416d4bb37d29746e86f2624f06b  
> > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > blob/master/src/main/java/org/elasticsearch/index/query/  
> > FilteredQueryParser.java#L54
> > 
> > --  
> > Ivan
> > 
> > On Sun, Jun 8, 2014 at 9:34 PM, Arkadiy Zabazhanov [kinw...@gmail.com](mailto:kinw...@gmail.com)  
> > wrote:
> > 
> > > Guys, I still need help, A've tried to change filtered query strategies.  
> > > It returns all the filtered results anyway for versions 1.0.0 - 1.2.1. When  
> > > this behavior was changed and how? Why don't I need match\_all for filtered  
> > > query with empty query?
> > > 
> > > пятница, 6 июня 2014 г., 7:14:28 UTC+7 пользователь Arkadiy Zabazhanov  
> > > написал:
> > > 
> > > > Yeah, I've got ehis already, thanks.
> > > > 
> > > > I'm still confused why filtered query is returning all results even  
> > > > without match\_all in filtered query.
> > > > 
> > > > четверг, 5 июня 2014 г., 6:21:03 UTC+7 пользователь Ivan Brusic написал:
> > > > 
> > > > > There is no label, but the change was made last December:
> > > > > 
> > > > > [Renamed top level `filter` to `post_filter`. by martijnvg · Pull Request #4461 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4461)
> > > > > 
> > > > > It appears that the REST API still supports the old notation, but the  
> > > > > change did break Java backwards compatibility
> > > > > 
> > > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/blob/master/)  
> > > > > src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71
> > > > > 
> > > > > --  
> > > > > Ivan
> > > > > 
> > > > > On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov [kinw...@gmail.com](mailto:kinw...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > Btw, Answer for the second question is top-level filter was renamed  
> > > > > > to post\_filter. That's awesome. So the first question is answered too.  
> > > > > > Filtered query is preferred.  
> > > > > > Still waiting for an answer for the third question. Since I didn't  
> > > > > > find filter to post\_filter renaming in changelog (  
> > > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find  
> > > > > > anything about new query behavior. I need just version where was it  
> > > > > > changed, please.
> > > > > > 
> > > > > > вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy  
> > > > > > Zabazhanov написал:
> > > > > > 
> > > > > > > Hello. Help me please, I'm confused. As far as I remember, there was  
> > > > > > > the only way to pass filters to search query - via filtered query. But  
> > > > > > > currently there is a top-level filter part of the query. However,  
> > > > > > > top-level filter affects query only and doesn't affect i.e. facets.  
> > > > > > > But filtered query filter affects both of the query and facets  
> > > > > > > facilities. Also, I remember there was a time I need to add  
> > > > > > > match\_all query to filtered query section if query was empty and  
> > > > > > > filters only was present. Otherwise returned empty set of documents. Since  
> > > > > > > I'm trying to create high-level Ruby library could you please answer  
> > > > > > > following questions:
> > > > > > > 
> > > > > > > 1. Which way is preferred now and in future: filtered top-level  
> > > > > > > query or top-level filter with top-level query?
> > > > > > > 2. How do you plan to resolve such an API inconsistency when  
> > > > > > > filtered query filter affects outside statements and top-level filter  
> > > > > > > doesn't affect some parts of request?
> > > > > > > 3. Why do I remember about match\_all feature and when did requests  
> > > > > > > started to return all the documents with empty query section in filtered  
> > > > > > > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > > > > > > match\_all, or constant\_score it just returns all the docs for me.
> > > > > > > 
> > > > > > > Thanks in advance.
> > > > > > 
> > > > > > --  
> > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40goo  
> > > > > > [glegroups.com](http://glegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> > > > > > 
> > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%  
> > > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > 
> > > 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/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> 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/CALY%3DcQDcnKWT%3DesSaw0urLmZVT470xMCQ98W7D5uHDLr0JZ5Gw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDcnKWT%3DesSaw0urLmZVT470xMCQ98W7D5uHDLr0JZ5Gw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Zabazhanov\_Arkady](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zabazhanov_arkady/32/1495_2.png) [@Zabazhanov\_Arkady](https://discuss.elastic.co/u/Zabazhanov_Arkady)\
**Post date:** [June 10, 2014, 5:00am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/9 "2014-06-10T05:00:40Z")

</div>

Reasonable approach, I think, I'll use it in my gem for now. But will wait  
for the answer as well just to bate my curiosity 🙂

понедельник, 9 июня 2014 г., 22:59:04 UTC+7 пользователь Ivan Brusic  
написал:

> I personally would not count any any default behaviors and would choose to  
> use match\_all explicitly in my calls. Having some filtered queries with no  
> query (default match all) and some with a more detailed query would be  
> inconsistent, so my preference would be to always have a query.
> 
> It comes down to personal preference. At this point, changing the default  
> behavior would be a breaking change, so I doubt the Elasticsearch team  
> would ever revert, but you never know...
> 
> --  
> Ivan
> 
> On Mon, Jun 9, 2014 at 12:50 AM, Arkadiy Zabazhanov \<[kinw...@gmail.com](mailto:kinw...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Yeah, it does matter because previously I had to add match\_all to empty  
> > queries if I was need to get all the results in case of empty query. It  
> > seems currently any empty query replaces with match\_all (this follows from  
> > your links), so I don't need to use it explicitly anymore. Am I correct?
> > 
> > I just need to confirm this to remove obsolete code from my library.
> > 
> > понедельник, 9 июня 2014 г., 14:28:07 UTC+7 пользователь Ivan Brusic  
> > написал:
> > 
> > > Does it matter? From what I can tell, some code was added in 0.90
> > > 
> > > [Add docs for the include\_named\_queries\_score param (#103155) · elastic/elasticsearch@47b5753 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/)  
> > > 6687ecb038b55416d4bb37d29746e86f2624f06b  
> > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > > blob/master/src/main/java/org/elasticsearch/index/query/  
> > > FilteredQueryParser.java#L54
> > > 
> > > --  
> > > Ivan
> > > 
> > > On Sun, Jun 8, 2014 at 9:34 PM, Arkadiy Zabazhanov [kinw...@gmail.com](mailto:kinw...@gmail.com)  
> > > wrote:
> > > 
> > > > Guys, I still need help, A've tried to change filtered query  
> > > > strategies. It returns all the filtered results anyway for versions 1.0.0 -  
> > > > 1.2.1. When this behavior was changed and how? Why don't I need match\_all  
> > > > for filtered query with empty query?
> > > > 
> > > > пятница, 6 июня 2014 г., 7:14:28 UTC+7 пользователь Arkadiy Zabazhanov  
> > > > написал:
> > > > 
> > > > > Yeah, I've got ehis already, thanks.
> > > > > 
> > > > > I'm still confused why filtered query is returning all results even  
> > > > > without match\_all in filtered query.
> > > > > 
> > > > > четверг, 5 июня 2014 г., 6:21:03 UTC+7 пользователь Ivan Brusic  
> > > > > написал:
> > > > > 
> > > > > > There is no label, but the change was made last December:
> > > > > > 
> > > > > > [Renamed top level `filter` to `post_filter`. by martijnvg · Pull Request #4461 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4461)
> > > > > > 
> > > > > > It appears that the REST API still supports the old notation, but the  
> > > > > > change did break Java backwards compatibility
> > > > > > 
> > > > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/blob/master/)  
> > > > > > src/main/java/org/elasticsearch/search/query/QueryPhase.java#L71
> > > > > > 
> > > > > > --  
> > > > > > Ivan
> > > > > > 
> > > > > > On Tue, Jun 3, 2014 at 8:11 PM, Arkadiy Zabazhanov \<[kinw...@gmail.com](mailto:kinw...@gmail.com)
> > > > > > 
> > > > > > > wrote:
> > > > > > 
> > > > > > > Btw, Answer for the second question is top-level filter was renamed  
> > > > > > > to post\_filter. That's awesome. So the first question is answered too.  
> > > > > > > Filtered query is preferred.  
> > > > > > > Still waiting for an answer for the third question. Since I didn't  
> > > > > > > find filter to post\_filter renaming in changelog (  
> > > > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/downloads/1-0-0/)) and I can't find  
> > > > > > > anything about new query behavior. I need just version where was it  
> > > > > > > changed, please.
> > > > > > > 
> > > > > > > вторник, 3 июня 2014 г., 19:27:17 UTC+7 пользователь Arkadiy  
> > > > > > > Zabazhanov написал:
> > > > > > > 
> > > > > > > > Hello. Help me please, I'm confused. As far as I remember, there  
> > > > > > > > was the only way to pass filters to search query - via filtered query. But  
> > > > > > > > currently there is a top-level filter part of the query. However,  
> > > > > > > > top-level filter affects query only and doesn't affect i.e. facets.  
> > > > > > > > But filtered query filter affects both of the query and facets  
> > > > > > > > facilities. Also, I remember there was a time I need to add  
> > > > > > > > match\_all query to filtered query section if query was empty and  
> > > > > > > > filters only was present. Otherwise returned empty set of documents. Since  
> > > > > > > > I'm trying to create high-level Ruby library could you please answer  
> > > > > > > > following questions:
> > > > > > > > 
> > > > > > > > 1. Which way is preferred now and in future: filtered top-level  
> > > > > > > > query or top-level filter with top-level query?
> > > > > > > > 2. How do you plan to resolve such an API inconsistency when  
> > > > > > > > filtered query filter affects outside statements and top-level filter  
> > > > > > > > doesn't affect some parts of request?
> > > > > > > > 3. Why do I remember about match\_all feature and when did requests  
> > > > > > > > started to return all the documents with empty query section in filtered  
> > > > > > > > query? I'm checking it right now on 1.2.0 and I don't need to use  
> > > > > > > > match\_all, or constant\_score it just returns all the docs for me.
> > > > > > > > 
> > > > > > > > Thanks in advance.
> > > > > > > 
> > > > > > > --  
> > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-734](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-734)  
> > > > > > > 7-4ca9-a9ea-65100a017673%[40googlegroups.com](http://40googlegroups.com)  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c8bddc46-7347-4ca9-a9ea-65100a017673%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > .
> > > > > > > 
> > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%  
> > > > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/811a5138-21d1-4ad0-a051-510a7494be65%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> > > > 
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3f0cd8ef-a31c-41a4-96b3-eef233b0fda9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > 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/63a6fbd4-1ab2-44bb-83d3-316fb8a8a2aa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/63a6fbd4-1ab2-44bb-83d3-316fb8a8a2aa%40googlegroups.com).  
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:23am UTC](https://discuss.elastic.co/t/queries-filters-and-match-all/17884/10 "2017-07-06T01:23:39Z")

</div>


