You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "Johnny R. Ruiz III" <jo...@yahoo.com> on 2007/10/21 03:44:29 UTC
How to do RangeQuery on a Computed Value of a Field?
Hi All,
I was looking for a way to do a range query on 2 numeric field of my index. The tricky part is, I don't directly use the numeric field but I have to use it on a computation formula to satisfy my criteria.
Hope this helps to explain my scenario:
pointX--> latitude X input by user.
pointY--> longitude Y input by user.
locX --> field indexed in lucene
locY --> field indexed in lucene
radius --> constant value as acceptable distance to be returned in search results (hits)
Conditon to satisfy:
Math.sqrt ( ( locX - pointX ) + ( locY - pointY ) ) <= radius
Is this possible in lucene? Has anyone did this before? Thanks in Advance!
My Actual Use Case is I want to return all location within a certain Radius of 1 mile given PointX and PointY from User.
Regards,
Johnny Ruiz
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: How to do RangeQuery on a Computed Value of a Field?
Posted by Erick Erickson <er...@gmail.com>.
There's also an example of something very similar in Lucene In Action.
Erick
On 10/20/07, Johnny R. Ruiz III <jo...@yahoo.com> wrote:
>
> Hi All,
>
> I was looking for a way to do a range query on 2 numeric field of my
> index. The tricky part is, I don't directly use the numeric field but I
> have to use it on a computation formula to satisfy my criteria.
>
> Hope this helps to explain my scenario:
>
> pointX--> latitude X input by user.
> pointY--> longitude Y input by user.
>
> locX --> field indexed in lucene
> locY --> field indexed in lucene
>
> radius --> constant value as acceptable distance to be returned in search
> results (hits)
>
> Conditon to satisfy:
>
> Math.sqrt ( ( locX - pointX ) + ( locY - pointY ) ) <= radius
>
> Is this possible in lucene? Has anyone did this before? Thanks in
> Advance!
>
> My Actual Use Case is I want to return all location within a certain
> Radius of 1 mile given PointX and PointY from User.
>
> Regards,
> Johnny Ruiz
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: How to do RangeQuery on a Computed Value of a Field?
Posted by Doron Cohen <DO...@il.ibm.com>.
You could use ValueSourceQuery for this - see
o.a.l.search.function. The trick is to create
your ValueSource class that is using two
FieldCacheSource objects - one for each location.
See http://issues.apache.org/jira/browse/LUCENE-1019
for a related example.
Note however that this solution would work well only
as long as the index is not huge. For a very large
index the loading of the entire two fields into the
FieldCache would become heavy, as will warming a new
searcher. This will be resolved once we heve a
payload-based ValueSource.
Doron
"Johnny R. Ruiz III" <jo...@yahoo.com> wrote on 21/10/2007 03:44:29:
> Hi All,
>
> I was looking for a way to do a range query on 2 numeric field
> of my index. The tricky part is, I don't directly use the
> numeric field but I have to use it on a computation formula to
> satisfy my criteria.
>
> Hope this helps to explain my scenario:
>
> pointX--> latitude X input by user.
> pointY--> longitude Y input by user.
>
> locX --> field indexed in lucene
> locY --> field indexed in lucene
>
> radius --> constant value as acceptable distance to be
> returned in search results (hits)
>
> Conditon to satisfy:
>
> Math.sqrt ( ( locX - pointX ) + ( locY - pointY ) ) <= radius
>
> Is this possible in lucene? Has anyone did this before?
> Thanks in Advance!
>
> My Actual Use Case is I want to return all location within a
> certain Radius of 1 mile given PointX and PointY from User.
>
> Regards,
> Johnny Ruiz
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org