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 John Blythe <jo...@curvolabs.com> on 2017/07/06 16:09:38 UTC

stats and pivots and sums

hi all.

i'm attempting to find similar purchases for a user. the volume of purchase
helps dictate the price point that they can expect. as such, i'm attempting
to determine the sum of the quantity field across all purchases per user.

i've got something like this as of yet:

facet=on&
> stats=true&
> stats.field={!tag=stats1}quantity&
> stats.facet=userId&
> facet.pivot={!stats=stats1.sum}userId&


i can see in the stats' faceting the "sum" property has what i'm looking
for. perhaps purchase #1 was a quantity of 2, purchase #2 was a quantity of
5, so the min is 2, the max is 5, and the sum is 7. that's exactly what i'm
wanting.

the facet.pivot, however, only shows me a count of how many records were a
part of that summation, so a count of 2 given my example above.

as you can see, i'd attempted to access the 'sum' property of the stats by
giving it a tag and trying to access with dot notation. no luck there.

i can use an algorithm to loop over the results of course but would love to
have the data more readily accessible when solr returns it AND even better
be able to filter query / facet query on it so that i can weed out results
that don't meet my criterion (e.g. fq=quantitySum:[* to $userQuantity])

thanks for any insights!

Re: stats and pivots and sums

Posted by John Blythe <jo...@curvolabs.com>.
will check it out, thanks-

-- 
*John Blythe*
Product Manager & Lead Developer

251.605.3071 | john@curvolabs.com
www.curvolabs.com

58 Adams Ave
Evansville, IN 47713

On Thu, Jul 6, 2017 at 12:37 PM, Erick Erickson <er...@gmail.com>
wrote:

> Have you looked at the JSON facet capabilities? It might work for you....
>
> Best,
> Erick
>
> On Thu, Jul 6, 2017 at 9:09 AM, John Blythe <jo...@curvolabs.com> wrote:
> > hi all.
> >
> > i'm attempting to find similar purchases for a user. the volume of
> purchase
> > helps dictate the price point that they can expect. as such, i'm
> attempting
> > to determine the sum of the quantity field across all purchases per user.
> >
> > i've got something like this as of yet:
> >
> > facet=on&
> >> stats=true&
> >> stats.field={!tag=stats1}quantity&
> >> stats.facet=userId&
> >> facet.pivot={!stats=stats1.sum}userId&
> >
> >
> > i can see in the stats' faceting the "sum" property has what i'm looking
> > for. perhaps purchase #1 was a quantity of 2, purchase #2 was a quantity
> of
> > 5, so the min is 2, the max is 5, and the sum is 7. that's exactly what
> i'm
> > wanting.
> >
> > the facet.pivot, however, only shows me a count of how many records were
> a
> > part of that summation, so a count of 2 given my example above.
> >
> > as you can see, i'd attempted to access the 'sum' property of the stats
> by
> > giving it a tag and trying to access with dot notation. no luck there.
> >
> > i can use an algorithm to loop over the results of course but would love
> to
> > have the data more readily accessible when solr returns it AND even
> better
> > be able to filter query / facet query on it so that i can weed out
> results
> > that don't meet my criterion (e.g. fq=quantitySum:[* to $userQuantity])
> >
> > thanks for any insights!
>

Re: stats and pivots and sums

Posted by Erick Erickson <er...@gmail.com>.
Have you looked at the JSON facet capabilities? It might work for you....

Best,
Erick

On Thu, Jul 6, 2017 at 9:09 AM, John Blythe <jo...@curvolabs.com> wrote:
> hi all.
>
> i'm attempting to find similar purchases for a user. the volume of purchase
> helps dictate the price point that they can expect. as such, i'm attempting
> to determine the sum of the quantity field across all purchases per user.
>
> i've got something like this as of yet:
>
> facet=on&
>> stats=true&
>> stats.field={!tag=stats1}quantity&
>> stats.facet=userId&
>> facet.pivot={!stats=stats1.sum}userId&
>
>
> i can see in the stats' faceting the "sum" property has what i'm looking
> for. perhaps purchase #1 was a quantity of 2, purchase #2 was a quantity of
> 5, so the min is 2, the max is 5, and the sum is 7. that's exactly what i'm
> wanting.
>
> the facet.pivot, however, only shows me a count of how many records were a
> part of that summation, so a count of 2 given my example above.
>
> as you can see, i'd attempted to access the 'sum' property of the stats by
> giving it a tag and trying to access with dot notation. no luck there.
>
> i can use an algorithm to loop over the results of course but would love to
> have the data more readily accessible when solr returns it AND even better
> be able to filter query / facet query on it so that i can weed out results
> that don't meet my criterion (e.g. fq=quantitySum:[* to $userQuantity])
>
> thanks for any insights!