[N to M] range search out of sum of field. howto search this?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[N to M] range search out of sum of field. howto search this?

Julian Davchev
Hi folks,
I got documents like
user:1   num:5
user:1   num: 8
user:5   num:7
user:5   num:1
....


I'd like to get per user that maches sum of num range 5 to 10
In this case it should return user 5  as 7+1=8 and is within range.
User 1 will be false cause sum of num is 5+8=13 hence outside range 5 to 10

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: [N to M] range search out of sum of field. howto search this?

Yonik Seeley-2-2
See frange:
http://www.lucidimagination.com/blog/2009/07/06/ranges-over-functions-in-solr-14/

fq={!frange l=5 u=10}sum(user,num)

-Yonik
http://www.lucidimagination.com



On Mon, Nov 23, 2009 at 8:49 AM, Julian Davchev <[hidden email]> wrote:

> Hi folks,
> I got documents like
> user:1   num:5
> user:1   num: 8
> user:5   num:7
> user:5   num:1
> ....
>
>
> I'd like to get per user that maches sum of num range 5 to 10
> In this case it should return user 5  as 7+1=8 and is within range.
> User 1 will be false cause sum of num is 5+8=13 hence outside range 5 to 10
>
> Thanks
>
Reply | Threaded
Open this post in threaded view
|

Re: [N to M] range search out of sum of field. howto search this?

hossman

: fq={!frange l=5 u=10}sum(user,num)

Hmmmm, One of us massivly missunderstood the original question - and i'm
pretty sure it's Yonik.

i don't think he wants results where the user field plus the num field are
in the range of 5-10 ... i think he wants the list of user Ids (which are
numbers in his examples, but could just as easily be strings) where the
sum of the "num" fields in all documents that have the same value in the
"user" field are the same.

I can't think of any easy way to do that ... it isn't the kind of thing an
Inverted Index is particuaraly good at.  but maybe there's soemthing in
the Field Collapsing patch (searching the archives/wiki will bring up
pointers) that can filter on stats like this?

: On Mon, Nov 23, 2009 at 8:49 AM, Julian Davchev <[hidden email]> wrote:
: > Hi folks,
: > I got documents like
: > user:1   num:5
: > user:1   num: 8
: > user:5   num:7
: > user:5   num:1
: > ....
: >
: >
: > I'd like to get per user that maches sum of num range 5 to 10
: > In this case it should return user 5  as 7+1=8 and is within range.
: > User 1 will be false cause sum of num is 5+8=13 hence outside range 5 to 10

-Hoss
Reply | Threaded
Open this post in threaded view
|

Re: [N to M] range search out of sum of field. howto search this?

Julian Davchev
Hi,
You got right what I am after.
Seems I will have to find a workaround for this one.
Also I am still stuck on 1.3 so..
Thanks a lot
JD

Chris Hostetter wrote:

> : fq={!frange l=5 u=10}sum(user,num)
>
> Hmmmm, One of us massivly missunderstood the original question - and i'm
> pretty sure it's Yonik.
>
> i don't think he wants results where the user field plus the num field are
> in the range of 5-10 ... i think he wants the list of user Ids (which are
> numbers in his examples, but could just as easily be strings) where the
> sum of the "num" fields in all documents that have the same value in the
> "user" field are the same.
>
> I can't think of any easy way to do that ... it isn't the kind of thing an
> Inverted Index is particuaraly good at.  but maybe there's soemthing in
> the Field Collapsing patch (searching the archives/wiki will bring up
> pointers) that can filter on stats like this?
>
> : On Mon, Nov 23, 2009 at 8:49 AM, Julian Davchev <[hidden email]> wrote:
> : > Hi folks,
> : > I got documents like
> : > user:1   num:5
> : > user:1   num: 8
> : > user:5   num:7
> : > user:5   num:1
> : > ....
> : >
> : >
> : > I'd like to get per user that maches sum of num range 5 to 10
> : > In this case it should return user 5  as 7+1=8 and is within range.
> : > User 1 will be false cause sum of num is 5+8=13 hence outside range 5 to 10
>
> -Hoss
>