Thanks for your support.

Because the null handling is one of the important things i decided to use 
another way.

I added a script in my data import handler that decides if object was audited
  function auditComplete(row) {
    var total = row.get('TOTAL');
    if (total == null || total < 90) {
      row.remove('audit_complete');
    } else {
      row.put('audit_complete', 1);
    }
    return row;
  }

When i add/update a document the same will be done in my code.
So i can do my query based on audit_complete field, because i only need to know 
how many are complete and how many not.

A drawback is surely that the "complete" limit of 90 is now implemented in two 
places (DIH script and my code).
But so far i can life with it.

Thank you
Per

> Gesendet: Mittwoch, 31. Mai 2017 um 17:28 Uhr
> Von: "Susheel Kumar" <susheel2...@gmail.com>
> An: solr-user@lucene.apache.org
> Betreff: Re: Facet ranges and stats
>
> 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