Hi,

Take a look at the includes/excludes feature on the terms aggregation. I 
think it should help with what you are trying to achieve.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values

Colin

On Monday, 8 December 2014 08:10:05 UTC, William Bowen wrote:
>
> I want to know if it is possible to filter the contents of an aggregation 
> rather than just the documents returned by the query. For instance, I have 
> a set of documents that have an array property called related concepts. I 
> want to count the number of documents for each related concept that meet my 
> search query. The resulting bucket looks like this:
>
> "related_concepts": {
>     "buckets": [
>         {
>             "key": "foo",
>             "doc_count": 3821
>         },
>         {
>             "key": "bar",
>             "doc_count": 3803
>         },
>         {
>             "key": "other",
>             "doc_count": 23
>         }
>     ]
> }
>
> Now imagine that there are 2,000 related concepts, however, using a graph 
> database I know I'm interested in a specific 5 or 6. Using the example 
> above, let's say for a specific result set I want to return the bucket 
> counts only for the terms "foo" and "other" but NOT include "bar" or any 
> other buckets. Sort of like a SQL WHERE or HAVING clause.
>
> I tried adding a filter to the aggregation, but it only seemed to filter 
> the numbers for the aggregations, not restrict which buckets are actually 
> displayed.
>
> I found this for 2.0 
> https://github.com/elasticsearch/elasticsearch/issues/8110, and looks 
> like it might solve my problem eventually (not in time for deadlines!), but 
> my use case is pretty simple. Is there anything I can do in the current 
> version of Elasticsearch to make this work? Am I overlooking something?
>
> Thanks!
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/5bb64118-b4d5-4f47-8c72-530040083381%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to