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:
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?
Take a look at the includes/excludes feature on the terms aggregation. I
think it should help with what you are trying to achieve.
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:
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.
Wow, this looks like exactly what I'm looking for. But I swear I spent most
of last month scouring documentation. Is this a relatively new feature? Or
am I just thick? Thanks, either way!
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:
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 GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine
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?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.