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 Zheng Lin Edwin Yeo <ed...@gmail.com> on 2016/08/03 03:58:47 UTC

Sum of all values in Function Query

Hi,

Would like to find out, is it possible for Solr to find a sum of all the
values that are returned in a query?

For example, when I does a search in which that is a field called "Amount"
with fieldType=float.
Is it possible for Solr to do return the sum of all the "Amount" that are
returned? If the main search query is *:*, then it should return the sum of
all the "Amount" that are present in the entire collection.

i have tried to use sum(Amount), but this doesn't work, as I believe what
the sum does is to just do the sum of the static amount in each of the
individual record, and not the entire search field records.

I'm using Solr 6.1.0

Regards,
Edwin

Re: Sum of all values in Function Query

Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
Hi Mikhail,

Yes, I have tried this, and it works for individual fields.

Currently I am trying to do something like sum(product(Quanity,Amount). Is
is possible to do it in a single Solr query?

Regards,
Edwin



On 3 August 2016 at 16:35, Mikhail Khludnev <mk...@apache.org> wrote:

> Edwin,
> Did you try something from http://yonik.com/solr-facet-functions/ ?
>
> On Wed, Aug 3, 2016 at 6:58 AM, Zheng Lin Edwin Yeo <ed...@gmail.com>
> wrote:
>
> > Hi,
> >
> > Would like to find out, is it possible for Solr to find a sum of all the
> > values that are returned in a query?
> >
> > For example, when I does a search in which that is a field called
> "Amount"
> > with fieldType=float.
> > Is it possible for Solr to do return the sum of all the "Amount" that are
> > returned? If the main search query is *:*, then it should return the sum
> of
> > all the "Amount" that are present in the entire collection.
> >
> > i have tried to use sum(Amount), but this doesn't work, as I believe what
> > the sum does is to just do the sum of the static amount in each of the
> > individual record, and not the entire search field records.
> >
> > I'm using Solr 6.1.0
> >
> > Regards,
> > Edwin
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>

Re: Sum of all values in Function Query

Posted by Mikhail Khludnev <mk...@apache.org>.
Edwin,
Did you try something from http://yonik.com/solr-facet-functions/ ?

On Wed, Aug 3, 2016 at 6:58 AM, Zheng Lin Edwin Yeo <ed...@gmail.com>
wrote:

> Hi,
>
> Would like to find out, is it possible for Solr to find a sum of all the
> values that are returned in a query?
>
> For example, when I does a search in which that is a field called "Amount"
> with fieldType=float.
> Is it possible for Solr to do return the sum of all the "Amount" that are
> returned? If the main search query is *:*, then it should return the sum of
> all the "Amount" that are present in the entire collection.
>
> i have tried to use sum(Amount), but this doesn't work, as I believe what
> the sum does is to just do the sum of the static amount in each of the
> individual record, and not the entire search field records.
>
> I'm using Solr 6.1.0
>
> Regards,
> Edwin
>



-- 
Sincerely yours
Mikhail Khludnev