Using terms_stats facet with Filter Facets to get "mean" value along with "count"


(revdev) #1

When I use filter facethttp://www.elasticsearch.org/guide/reference/api/search/facets/filter-facet.html with
terms_stats facet, I get just counts. Is there anyway, I can apply
filters/query to terms_stats facet and get other metrics like "total",
"mean", "min", "max" etc?
Thanks!

--


(Rafał Kuć) #2

Hello!

You can include filters in your facets calculation, for example like this:

{

"query" : {

"match_all" : {}

},

"facets" : {

"facet1" : {

"terms" : {

"field" : "tags"

},

"facet_filter" : {

"term" : {


 "category" : "books"


}

}

}

}

}

More about this can be found here: http://www.elasticsearch.org/guide/reference/api/search/facets/

--

Regards,

Rafał Kuć

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch

When I use filter facet with terms_stats facet, I get just counts. Is there anyway, I can apply filters/query to terms_stats facet and get other metrics like "total", "mean", "min", "max" etc?

Thanks!

--


(revdev) #3

oops, I was using just "filter" rather than "facet_filter" . doh!
Thanks for pointing that out. ElasticSearch is way complicated for my
little brain. :slight_smile:

On Saturday, October 27, 2012 11:25:28 AM UTC-7, Rafał Kuć wrote:

Hello!

You can include filters in your facets calculation, for example like this:

{
"query" : {
"match_all" : {}
},
"facets" : {
"facet1" : {
"terms" : {
"field" : "tags"
},
"facet_filter" : {
"term" : {
"category" : "books"
}
}
}
}
}

More about this can be found here:
http://www.elasticsearch.org/guide/reference/api/search/facets/

*--
Regards,
Rafał Kuć
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch -
ElasticSearch

When I use filter facethttp://www.elasticsearch.org/guide/reference/api/search/facets/filter-facet.html with
terms_stats facet, I get just counts. Is there anyway, I can apply
filters/query to terms_stats facet and get other metrics like "total",
"mean", "min", "max" etc?
Thanks!

--

--


(system) #4