Aggregation not limited to filter?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Aggregation not limited to filter?

James Green
I must be doing something stupid!

Using the Java client I can perform a search with a filter and iterate over the hits. I see exactly the right source documents.

If I add an aggregation, I see the expected keyAsText string but the docCount reflects the volume if the filter had not been applied.

I expected the aggregation to be restricted to the results within that filter?

Thanks,

James

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxkmZVfDhkJW-bWPrRs5BMzTem-2zCQRWeF%2BLQCR2L5sA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Aggregation not limited to filter?

James Macdonald
I had a similar problem recently and solved it by moving my filter into a filtered query (leaving the query as a match_all), see documentation here http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-filtered-query.html

I am not certain why filters do not restrict the scope of the aggregates, but queries do, but I suspect it interprets the filter (not wrapped in a filtered_query) as a post_filter (http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-post-filter.html). Maybe someone else actually knows why.


Hope that helps,
James

On Fri, Apr 10, 2015 at 11:39 AM, James Green <[hidden email]> wrote:
I must be doing something stupid!

Using the Java client I can perform a search with a filter and iterate over the hits. I see exactly the right source documents.

If I add an aggregation, I see the expected keyAsText string but the docCount reflects the volume if the filter had not been applied.

I expected the aggregation to be restricted to the results within that filter?

Thanks,

James

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxkmZVfDhkJW-bWPrRs5BMzTem-2zCQRWeF%2BLQCR2L5sA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAABsnTbD0JgcpMCMWuzjVC1W3C-pt6pC6PJG0xT31O44MZQs%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Aggregation not limited to filter?

James Green
Indeed. I had used postFilter to add my filters. The documentation for filters doesn't show how to use a query with a matchAll and a bunch of filters so I blindly followed IDE auto-complete.

Lesson learned.

On 10 April 2015 at 21:17, James Macdonald <[hidden email]> wrote:
I had a similar problem recently and solved it by moving my filter into a filtered query (leaving the query as a match_all), see documentation here http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-filtered-query.html

I am not certain why filters do not restrict the scope of the aggregates, but queries do, but I suspect it interprets the filter (not wrapped in a filtered_query) as a post_filter (http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-post-filter.html). Maybe someone else actually knows why.


Hope that helps,
James

On Fri, Apr 10, 2015 at 11:39 AM, James Green <[hidden email]> wrote:
I must be doing something stupid!

Using the Java client I can perform a search with a filter and iterate over the hits. I see exactly the right source documents.

If I add an aggregation, I see the expected keyAsText string but the docCount reflects the volume if the filter had not been applied.

I expected the aggregation to be restricted to the results within that filter?

Thanks,

James

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxkmZVfDhkJW-bWPrRs5BMzTem-2zCQRWeF%2BLQCR2L5sA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAABsnTbD0JgcpMCMWuzjVC1W3C-pt6pC6PJG0xT31O44MZQs%3DA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxDfHvCicw5rewNOAun5Vy2qZe8X_awGD3wR8B-vVZY-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Aggregation not limited to filter?

James Green
In reply to this post by James Macdonald
Indeed. I had used postFilter to add my filters. The documentation for filters doesn't show how to use a query with a matchAll and a bunch of filters so I blindly followed IDE auto-complete.

Lesson learned.

On 10 April 2015 at 21:17, James Macdonald <[hidden email]> wrote:
I had a similar problem recently and solved it by moving my filter into a filtered query (leaving the query as a match_all), see documentation here http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-filtered-query.html

I am not certain why filters do not restrict the scope of the aggregates, but queries do, but I suspect it interprets the filter (not wrapped in a filtered_query) as a post_filter (http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-post-filter.html). Maybe someone else actually knows why.


Hope that helps,
James

On Fri, Apr 10, 2015 at 11:39 AM, James Green <[hidden email]> wrote:
I must be doing something stupid!

Using the Java client I can perform a search with a filter and iterate over the hits. I see exactly the right source documents.

If I add an aggregation, I see the expected keyAsText string but the docCount reflects the volume if the filter had not been applied.

I expected the aggregation to be restricted to the results within that filter?

Thanks,

James

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxkmZVfDhkJW-bWPrRs5BMzTem-2zCQRWeF%2BLQCR2L5sA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAABsnTbD0JgcpMCMWuzjVC1W3C-pt6pC6PJG0xT31O44MZQs%3DA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxhjdOQrfqy9Upsvnh%2B%2BgHmFDwqw%3DQqjHW2Z7DUm7BvJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Aggregation not limited to filter?

Ivan Brusic
In reply to this post by James Green

Which version are you using! The old post filter methods simply named filter, should have been removed, or at least deprecated.

Cheers,

Ivan

On Apr 13, 2015 1:33 PM, "James Green" <[hidden email]> wrote:
Indeed. I had used postFilter to add my filters. The documentation for filters doesn't show how to use a query with a matchAll and a bunch of filters so I blindly followed IDE auto-complete.

Lesson learned.

On 10 April 2015 at 21:17, James Macdonald <[hidden email]> wrote:
I had a similar problem recently and solved it by moving my filter into a filtered query (leaving the query as a match_all), see documentation here http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-filtered-query.html

I am not certain why filters do not restrict the scope of the aggregates, but queries do, but I suspect it interprets the filter (not wrapped in a filtered_query) as a post_filter (http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-post-filter.html). Maybe someone else actually knows why.


Hope that helps,
James

On Fri, Apr 10, 2015 at 11:39 AM, James Green <[hidden email]> wrote:
I must be doing something stupid!

Using the Java client I can perform a search with a filter and iterate over the hits. I see exactly the right source documents.

If I add an aggregation, I see the expected keyAsText string but the docCount reflects the volume if the filter had not been applied.

I expected the aggregation to be restricted to the results within that filter?

Thanks,

James

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxkmZVfDhkJW-bWPrRs5BMzTem-2zCQRWeF%2BLQCR2L5sA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAABsnTbD0JgcpMCMWuzjVC1W3C-pt6pC6PJG0xT31O44MZQs%3DA%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BaxDfHvCicw5rewNOAun5Vy2qZe8X_awGD3wR8B-vVZY-A%40mail.gmail.com.
For more options, visit 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCy8fZvnKZpuGFJMWXvt9MFQdUQzFO8au77mZj7r3VW0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.