Aggegation framework - Is there facet_filter analogue available?


(Kaspars Sprogis) #1

I just tried out new aggregation framework and wanted to see if new
aggregation could resolve my previously discussed and unresolved problem:
https://groups.google.com/forum/?fromgroups#!topic/elasticsearch/-oiL2hvjieY

Since aggregation framework is planned as replacement for facets, i am
wondering how can i filter term aggregations, without loosing actual terms,
because as soon as i add "filter", then aggregations return only count.
So i am looking something like "facet_filter" for facets.
Or this is feature is not yet developed?

Here is the mapping and sample data:

Here is query i tried:
{
"query": {
"match": {
"credits.person_id": 1
}
},
"aggs": {
"departments": {
"terms": {
"field": "credits.department"
}
}
},
"size": 0
}

Results:
"aggregations": {
"departments": {
"buckets": [
{
"key": "producer",
"doc_count": 2
},
{
"key": "director",
"doc_count": 2
},
{
"key": "actor",
"doc_count": 2
}
]
}
}

When i tried adding filter i got following result, without ability to see
term value:

Query:
{
"query": {
"match": {
"credits.person_id": 1
}
},
"aggs": {
"departments": {
"terms": {
"field": "credits.department"
},
"filter": {
"term": {
"genre": "comedy"
}
}
}
},
"size": 0
}

Result:
"aggregations": {
"departments": {
"doc_count": 1
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f9c0b90f-8d79-4e3f-bbbf-58df4c083294%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrien Grand) #2

Hi,

The issue is that you are trying to define two aggregations (a terms and a
filter) under the same name, and the aggregations framework only takes into
account one of them. I tried to fix your last query in the following
example: https://gist.github.com/jpountz/7986093

On Sat, Dec 14, 2013 at 8:44 PM, Kaspars Sprogis darklow@gmail.com wrote:

I just tried out new aggregation framework and wanted to see if new
aggregation could resolve my previously discussed and unresolved problem:

https://groups.google.com/forum/?fromgroups#!topic/elasticsearch/-oiL2hvjieY

Since aggregation framework is planned as replacement for facets, i am
wondering how can i filter term aggregations, without loosing actual terms,
because as soon as i add "filter", then aggregations return only count.
So i am looking something like "facet_filter" for facets.
Or this is feature is not yet developed?

Here is the mapping and sample data:
https://gist.github.com/darklow/7957463

Here is query i tried:
{
"query": {
"match": {
"credits.person_id": 1
}
},
"aggs": {
"departments": {
"terms": {
"field": "credits.department"
}
}
},
"size": 0
}

Results:
"aggregations": {
"departments": {
"buckets": [
{
"key": "producer",
"doc_count": 2
},
{
"key": "director",
"doc_count": 2
},
{
"key": "actor",
"doc_count": 2
}
]
}
}

When i tried adding filter i got following result, without ability to see
term value:

Query:
{
"query": {
"match": {
"credits.person_id": 1
}
},
"aggs": {
"departments": {
"terms": {
"field": "credits.department"
},
"filter": {
"term": {
"genre": "comedy"
}
}
}
},
"size": 0
}

Result:
"aggregations": {
"departments": {
"doc_count": 1
}
}

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/f9c0b90f-8d79-4e3f-bbbf-58df4c083294%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7OyVj2Ot6Crp9Eu%3DtGwht87XDtJ5oNhnkm6LRF4-dSLw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Kaspars Sprogis) #3

Sorry, my bad, used wrong hierarchy/syntax.
Thank you for sharing, there are very few advanced examples on new
aggregation framework right now, so this is very helpful.

On Monday, December 16, 2013 2:17:26 PM UTC+2, Adrien Grand wrote:

Hi,

The issue is that you are trying to define two aggregations (a terms and a
filter) under the same name, and the aggregations framework only takes into
account one of them. I tried to fix your last query in the following
example: https://gist.github.com/jpountz/7986093

On Sat, Dec 14, 2013 at 8:44 PM, Kaspars Sprogis <dar...@gmail.com<javascript:>

wrote:

I just tried out new aggregation framework and wanted to see if new
aggregation could resolve my previously discussed and unresolved problem:

https://groups.google.com/forum/?fromgroups#!topic/elasticsearch/-oiL2hvjieY

Since aggregation framework is planned as replacement for facets, i am
wondering how can i filter term aggregations, without loosing actual terms,
because as soon as i add "filter", then aggregations return only count.
So i am looking something like "facet_filter" for facets.
Or this is feature is not yet developed?

Here is the mapping and sample data:
https://gist.github.com/darklow/7957463

Here is query i tried:
{
"query": {
"match": {
"credits.person_id": 1
}
},
"aggs": {
"departments": {
"terms": {
"field": "credits.department"
}
}
},
"size": 0
}

Results:
"aggregations": {
"departments": {
"buckets": [
{
"key": "producer",
"doc_count": 2
},
{
"key": "director",
"doc_count": 2
},
{
"key": "actor",
"doc_count": 2
}
]
}
}

When i tried adding filter i got following result, without ability to see
term value:

Query:
{
"query": {
"match": {
"credits.person_id": 1
}
},
"aggs": {
"departments": {
"terms": {
"field": "credits.department"
},
"filter": {
"term": {
"genre": "comedy"
}
}
}
},
"size": 0
}

Result:
"aggregations": {
"departments": {
"doc_count": 1
}
}

--
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 <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/f9c0b90f-8d79-4e3f-bbbf-58df4c083294%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d3b8938d-1859-442c-a947-9baf2b405548%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4