You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Per Newgro <pe...@gmx.ch> on 2017/06/01 07:16:17 UTC

Aw: Re: Facet ranges and stats

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" <su...@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 <pe...@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
> >
> 

Aw: Re: Re: Facet ranges and stats

Posted by Per Newgro <pe...@gmx.ch>.
Thank you for your offer. But i think i need to think about the concept at all.
I need to configure the limit in the database and use in in all appropriate places.
I already have a clue how to do it - but lack of time :-)

> Gesendet: Donnerstag, 01. Juni 2017 um 15:00 Uhr
> Von: "Susheel Kumar" <su...@gmail.com>
> An: solr-user@lucene.apache.org
> Betreff: Re: Re: Facet ranges and stats
>
> Great, it worked out.  If you want to share where and in what code you have
> 90 configured, we can brainstorm if we can simplify it to have only one
> place.
> 
> On Thu, Jun 1, 2017 at 3:16 AM, Per Newgro <pe...@gmx.ch> wrote:
> 
> > 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" <su...@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 <pe...@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
> > > >
> > >
> >
> 

Re: Re: Facet ranges and stats

Posted by Susheel Kumar <su...@gmail.com>.
Great, it worked out.  If you want to share where and in what code you have
90 configured, we can brainstorm if we can simplify it to have only one
place.

On Thu, Jun 1, 2017 at 3:16 AM, Per Newgro <pe...@gmx.ch> wrote:

> 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" <su...@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 <pe...@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
> > >
> >
>