How difficult would it be to compute a sum by writing a custom facet

handler? For example, the terms facet handler computes a count of the

number of documents with each value of a specified field; instead of

counting the number of documents, for each document I want to look up the

value of another field and sum it. Another way to look at this is: the

terms facet handler allows me to compute "select X, count(*) from T group

by X" and I want to compute "select X, sum(Y) from T group by X". I've

started looking over the code in

https://github.com/elasticsearch/elasticsearch/tree/master/src/main/java/org/elasticsearch/search/facet

Any pointers to help me get started?

--