I have documents in solr that look like this:
{
  "id": "acme-1",
  "manufacturer": "acme",
  "product_name": "Foo",
  "price": 3.4
}
 
There are about
150,000 manufacturers, each of which have between 20,000 and 1,000,000 products.  
I'd like to return the sum of all prices that are in the range [100, 200], faceted by manufacturer.  In other words, for each manufacturer, sum the prices of all products for that manufacturer,
and return the sum and the manufacturer name.  For example:
[
  {
    "manufacturer": "acme",
    "sum": 150.5
  },
  {
    "manufacturer": "Johnson,
Inc.",
    "sum": 167.0
  },
...
]
 
I tried this:
q=*:*&rows=0&stats=true&stats.field={!tag=piv1 sum=true}price&facet=true&facet.pivot={!stats=piv1}manufacturer
which "works" on a test
subset of 1,000 manufacturers.  However, there are two problems:
1) This query returns all the manufacturers, so I have to iterate over the entire response object to extract the ones I want.
2) The query on the whole data set takes more than 600 seconds to return, which doesn't fit
our target response time
 
How can I perform this query?
We're using solr version 5.5.5.
 

 
Thanks,
Chris
 
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB