Hi, If you mean adding up numeric values stored in fields - no, Solr doesn't do this by default. We had a similar requirement for this, and created a custom SearchComponent to handle sum, average, stats etc. There are a number of things you need to bear in mind, such as: * Handling errors when a query asks for sums on fields that are non-numeric * Performance issues - e.g. are you willing to wait to add up 50 million fields of stringified numbers * How to return result payloads in a client-friendly way * Be prepared to coalesce results from multi-shard/distributed queries. It's not trivial, but it is do-able.
Peter On Thu, Jul 11, 2013 at 12:56 PM, Jamshaid Ashraf <jamshaid...@gmail.com>wrote: > Hi, > > I'm a new solr user, I wanted to know is there any way to apply sum on a > field in a result document of group query? > > Following is the query and its result set, I wanted to apply sum on 'price' > filed grouping on type: > > > *Sample input:* > > <doc> > <str name="id">3</str> > <str name="type">Caffe</str> > <str name="content">Yummm Drinking a latte at Caffe Grecco in SF shistoric > North Beach Learning text analysis with SolrInAction by Manning on my > iPad</str> > <long name="_version_">1440257540658036736</long> > <int name="price">250</int> > </doc> > <doc> > <str name="id">1</str> > <str name="type">Caffe</str> > <str name="content">Yummm Drinking a latte at Caffe Grecco in SF shistoric > North Beach Learning text analysis with SolrInAction by Manning on my > iPad</str> > <long name="_version_">1440257592044552192</long> > <int name="price">100</int> > </doc> > * > * > *Query:* > > http://localhost:8080/solr/collection2/select?q=caffe&df=content&group=true&group.field=type > > your help will be greatly appreciated! > > Regards, > Jamshaid >