The aggregation takes into account a query - but not a post-filter. I'm not 
sure of the rationale behind the difference.

The java api for traversing results is quite painful - but I think a good 
part of that is due to Java & the fact that there is very little 
polymorphic behaviour between aggregation results (some have single 
results, others have buckets, some have sub-aggregations, some dont).
The only alternative that I can think of is a completely type-less 
navigation of the data - which does little more than navigate the JSON 
document.

Hope that helps a bit.



On Monday, 8 September 2014 10:26:44 UTC+1, Emanuel Buzek wrote:
>
> Hi there,
> I just used the elasticsearch aggregations through the Java API for the 
> first time.
>
> All I wanted was a simple min/max/sum/avg, so I used the Stats 
> aggregation. However, I was very surprised that the filter in the 
> SearchRequestBuilder is ignored, so I had to wrap the Stats Aggregation 
> into FilterAggregation.
>
> Getting the aggregation result seems a bit tedious:
>
> InternalStats stats = 
> (InternalStats)((InternalFilter)a).getAggregations().asList().get(0);
>
> Maybe I am using the Java API wrong (I hope I am, otherwise it's imho 
> poorly designed.) Can anyone point me to an example how to access the 
> aggregation results from Java better?
>
>
> Also, I think that the aggregation should be filtered by default. If I 
> specify the filter with a query or post filter:
>
> queryBuilder = QueryBuilders.filteredQuery(queryBuilder, filterBuilder);
>
>   searchRequestBuilder.setQuery(queryBuilder);
>
> and then add an aggregation GET to the same searchRequestBuilder, I think 
> it's very unintuitive if the aggregation is computed globally. Anyone has 
> this feeling as well?
>
> thanks, emanuel
>
> -- 
> Emanuel Buzek
> Software Engineer, ROKE.cz <http://www.roke.cz>
> tel: +420 776 54 26 26
>  

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/a2e3a1e1-912a-4257-b938-6036d0c9d3ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to