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 Tomás Fernández Löbbe <to...@gmail.com> on 2025/06/06 20:01:52 UTC
Point query on a LatLonPoint field
Hi All,
I just noticed that If I add a document with a LatLonPoint field with a
latitude and longitude, and then I do a query using
"LatLonPoint.newGeometryQuery("location",
ShapeField.QueryRelation.INTERSECTS, new Point(latitude, longitude))" with
the same latitude and longitude it won't match. Is this expected? If I do a
Distance query instead, even with radius 0 the document will match.
My test here:
https://github.com/tflobbe/lucene/commit/a55e465a48dd8f5f978f4241a0a89e051044b6d3
Tomas
Re: Point query on a LatLonPoint field
Posted by Ignacio Vera <iv...@gmail.com>.
I tried to move the API toward this direction (
https://github.com/apache/lucene/issues/10194) but I got pushed back.
On Mon, Jun 9, 2025 at 8:22 PM Tomás Fernández Löbbe <to...@gmail.com>
wrote:
> Thanks a lot Ignacio,
> This does seem to work. I'm wondering why this is not part of the query
> processing itself? Are there situations in which someone would not want
> this behavior?
>
> Tomas
>
> On Mon, Jun 9, 2025 at 11:02 AM Ignacio Vera <iv...@gmail.com> wrote:
>
> > That is actually expected as the query is trying to match the
> > original point with the encoded point in the index, therefore is not
> > matching. There are other cases where results are not as expected, for
> > example if you index the points from a polygon and then you make a
> polygon
> > query using that polygon, some of the points will intersect and some
> others
> > won't.
> >
> > In order to avoid these cases, what I do is to quantize the query
> > geometries (encode and decode all points). I found this is a more apple
> to
> > apple comparison, and the results are closer to what I would expect.
> >
> > Hope this helps,
> >
> > Ignacio
> >
> >
> > On Fri, Jun 6, 2025 at 10:02 PM Tomás Fernández Löbbe <
> > tomasflobbe@gmail.com>
> > wrote:
> >
> > > Hi All,
> > > I just noticed that If I add a document with a LatLonPoint field with a
> > > latitude and longitude, and then I do a query using
> > > "LatLonPoint.newGeometryQuery("location",
> > > ShapeField.QueryRelation.INTERSECTS, new Point(latitude, longitude))"
> > with
> > > the same latitude and longitude it won't match. Is this expected? If I
> > do a
> > > Distance query instead, even with radius 0 the document will match.
> > >
> > > My test here:
> > >
> > >
> >
> https://github.com/tflobbe/lucene/commit/a55e465a48dd8f5f978f4241a0a89e051044b6d3
> > >
> > > Tomas
> > >
> >
>
Re: Point query on a LatLonPoint field
Posted by Tomás Fernández Löbbe <to...@gmail.com>.
Thanks a lot Ignacio,
This does seem to work. I'm wondering why this is not part of the query
processing itself? Are there situations in which someone would not want
this behavior?
Tomas
On Mon, Jun 9, 2025 at 11:02 AM Ignacio Vera <iv...@gmail.com> wrote:
> That is actually expected as the query is trying to match the
> original point with the encoded point in the index, therefore is not
> matching. There are other cases where results are not as expected, for
> example if you index the points from a polygon and then you make a polygon
> query using that polygon, some of the points will intersect and some others
> won't.
>
> In order to avoid these cases, what I do is to quantize the query
> geometries (encode and decode all points). I found this is a more apple to
> apple comparison, and the results are closer to what I would expect.
>
> Hope this helps,
>
> Ignacio
>
>
> On Fri, Jun 6, 2025 at 10:02 PM Tomás Fernández Löbbe <
> tomasflobbe@gmail.com>
> wrote:
>
> > Hi All,
> > I just noticed that If I add a document with a LatLonPoint field with a
> > latitude and longitude, and then I do a query using
> > "LatLonPoint.newGeometryQuery("location",
> > ShapeField.QueryRelation.INTERSECTS, new Point(latitude, longitude))"
> with
> > the same latitude and longitude it won't match. Is this expected? If I
> do a
> > Distance query instead, even with radius 0 the document will match.
> >
> > My test here:
> >
> >
> https://github.com/tflobbe/lucene/commit/a55e465a48dd8f5f978f4241a0a89e051044b6d3
> >
> > Tomas
> >
>
Re: Point query on a LatLonPoint field
Posted by Ignacio Vera <iv...@gmail.com>.
That is actually expected as the query is trying to match the
original point with the encoded point in the index, therefore is not
matching. There are other cases where results are not as expected, for
example if you index the points from a polygon and then you make a polygon
query using that polygon, some of the points will intersect and some others
won't.
In order to avoid these cases, what I do is to quantize the query
geometries (encode and decode all points). I found this is a more apple to
apple comparison, and the results are closer to what I would expect.
Hope this helps,
Ignacio
On Fri, Jun 6, 2025 at 10:02 PM Tomás Fernández Löbbe <to...@gmail.com>
wrote:
> Hi All,
> I just noticed that If I add a document with a LatLonPoint field with a
> latitude and longitude, and then I do a query using
> "LatLonPoint.newGeometryQuery("location",
> ShapeField.QueryRelation.INTERSECTS, new Point(latitude, longitude))" with
> the same latitude and longitude it won't match. Is this expected? If I do a
> Distance query instead, even with radius 0 the document will match.
>
> My test here:
>
> https://github.com/tflobbe/lucene/commit/a55e465a48dd8f5f978f4241a0a89e051044b6d3
>
> Tomas
>