Filter works, but facets are for entire dataset. How do I limit them?

I would like to only show the facets that are found within the
filter. How can I limit them ? Thanks.

var query = {
"filter":{
"terms":{
"tags.split": ["person","politician"],
"minimum_match": 1
}
},
"facets":{
"tags":{
"terms" : { "field": "tags", "size":20 }
},
},
"sort":[
{ "meta.view_count": "desc" },
{ "meta.answer_count": "desc" }
],
"size": 20
}

have a look at "filtered":

Peter.

On Feb 15, 6:51 am, Arron asch...@gmail.com wrote:

I would like to only show the facets that are found within the
filter. How can I limit them ? Thanks.

var query = {
"filter":{
"terms":{
"tags.split": ["person","politician"],
"minimum_match": 1
}
},
"facets":{
"tags":{
"terms" : { "field": "tags", "size":20 }
},
},
"sort":[
{ "meta.view_count": "desc" },
{ "meta.answer_count": "desc" }
],
"size": 20
}

filted query (within the search query element) will cause the facets to only be aggregated to the provided query (which is filtered). If additional filtering is required per specific facet, you can have a facet_filter associated with a facet.

On Wednesday, February 15, 2012 at 11:07 AM, Karussell wrote:

have a look at "filtered":

Elasticsearch Platform — Find real-time answers at scale | Elastic
Bird’s Eye View on ElasticSearch its Query DSL | Karussell

Peter.

On Feb 15, 6:51 am, Arron <asch...@gmail.com (http://gmail.com)> wrote:

I would like to only show the facets that are found within the
filter. How can I limit them ? Thanks.

var query = {
"filter":{
"terms":{
"tags.split": ["person","politician"],
"minimum_match": 1
}
},
"facets":{
"tags":{
"terms" : { "field": "tags", "size":20 }
},
},
"sort":[
{ "meta.view_count": "desc" },
{ "meta.answer_count": "desc" }
],
"size": 20
}