Just Pushed: Enhancements to Term Facets


Just pushed support to provide several fields for term facet to run on:
http://github.com/elasticsearch/elasticsearch/issues/issue/405. Later, when
working on another enhancement for terms facet (explained below), it struck
me that if you execute a search request with several term facets (on
different fields) but use the same facet name for them, they will get
aggregated automatically :). So basically, the above feature can now be used
by simply execute two term facets, with the same facet name, on two
different fields.

This feature :), which is a side effect of the map reduce nature of how
facets works, can be used on any facet of the same type (for example, have
histogram facet executed on different fields and use the same facet name).

The next enhancement to term facet is the ability to just use a script in
it. When providing a field name, the script is used to filter out terms.
When providing just script without a field, then the script will be
responsible for producing terms.