Hi,

You may want to explore the JSON facets.  The closest I can go to meet
above requirement is below query (replace inStock with your rank field and
price below with total.  Null handling something also will have to look.

-- 
Susheel

curl http://localhost:8983/solr/techproducts/query -d 'q=*:*&

              json.facet={inStocks:{ terms:{
                            field: inStock,
                            limit: 5,
                            facet:{
                                priceRange:{ range:{  // nested terms
facet will be executed for the top 5 genre buckets of the parent
                                  field: price,
                                  start : 0,
                                      end : 90,
                                      gap : 90,
                                      other : "after"
                                }}
                              }
                          }}
                          }'


On Wed, May 31, 2017 at 7:33 AM, Per Newgro <per.new...@gmx.ch> wrote:

> Hello,
>
> i would like to generate some stats on my facets. This is working so far.
> My problem is that i don't know how to generate Ranges on my facets and
> calculate the stats for it.
>
> I have two fields in my schema -> rank(string) and total(float, nullable)
> Rank can be A or B or C. In case my object was audited document contains a
> total value (78 or 45 or ...). Otherwise the value is null.
>
> What i need to calculate per Rank is the count of documents having a total
> value >= 90 and the count of the other documents (null or < 90).
>
> My solution would be to implement 2 queries. But what i learned so far:
> Solr is build to avoid that.
>
> Can you please give me hint how i could solve this problem.
>
> Thanks for your support
> Per
>

Reply via email to