[GitHub] [lucene] jpountz commented on a diff in pull request #897: LUCENE-10266 Move nearest-neighbor search on points to core

2022-05-24 Thread GitBox


jpountz commented on code in PR #897:
URL: https://github.com/apache/lucene/pull/897#discussion_r880768892


##
lucene/core/src/java/org/apache/lucene/document/NearestNeighbor.java:
##
@@ -220,7 +216,7 @@ public Relation compare(byte[] minPackedValue, byte[] 
maxPackedValue) {
   }
 
   /** Holds one hit from {@link NearestNeighbor#nearest} */
-  static class NearestHit {
+  public static class NearestHit {

Review Comment:
   can it remain pkg-private too?



##
lucene/core/src/java/org/apache/lucene/document/LatLonPoint.java:
##
@@ -362,4 +375,71 @@ public static Query newDistanceFeatureQuery(
 }
 return query;
   }
+
+  /**
+   * Finds the {@code n} nearest indexed points to the provided point, 
according to Haversine
+   * distance.
+   *
+   * This is functionally equivalent to running {@link MatchAllDocsQuery} 
with a {@link
+   * LatLonDocValuesField#newDistanceSort}, but is far more efficient since it 
takes advantage of
+   * properties the indexed BKD tree. Multi-valued fields are currently not 
de-duplicated, so if a
+   * document had multiple instances of the specified field that make it into 
the top n, that
+   * document will appear more than once.
+   *
+   * Documents are ordered by ascending distance from the location. The 
value returned in {@link
+   * FieldDoc} for the hits contains a Double instance with the distance in 
meters.
+   *
+   * @param searcher IndexSearcher to find nearest points from.
+   * @param field field name. must not be null.
+   * @param latitude latitude at the center: must be within standard +/-90 
coordinate bounds.
+   * @param longitude longitude at the center: must be within standard +/-180 
coordinate bounds.
+   * @param n the number of nearest neighbors to retrieve.
+   * @return TopFieldDocs containing documents ordered by distance, where the 
field value for each
+   * {@link FieldDoc} is the distance in meters
+   * @throws IllegalArgumentException if the underlying PointValues is not a 
{@code
+   * Lucene60PointsReader} (this is a current limitation), or if {@code 
field} or {@code

Review Comment:
   we removed this limitation that `Lucene60PointsReader` is required



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org



[GitHub] [lucene] jpountz commented on a diff in pull request #897: LUCENE-10266 Move nearest-neighbor search on points to core

2022-05-20 Thread GitBox


jpountz commented on code in PR #897:
URL: https://github.com/apache/lucene/pull/897#discussion_r877887683


##
lucene/core/src/java/org/apache/lucene/document/LatLonPoint.java:
##
@@ -362,4 +377,72 @@ public static Query newDistanceFeatureQuery(
 }
 return query;
   }
+
+  /**
+   * Finds the {@code n} nearest indexed points to the provided point, 
according to Haversine
+   * distance.
+   *
+   * This is functionally equivalent to running {@link MatchAllDocsQuery} 
with a {@link
+   * LatLonDocValuesField#newDistanceSort}, but is far more efficient since it 
takes advantage of
+   * properties the indexed BKD tree. Currently this only works with {@link 
Lucene90PointsFormat}

Review Comment:
   this point that it only works with Lucene90PointsFormat is no longer true, 
can you remove it?



##
lucene/core/src/java/org/apache/lucene/search/NearestNeighbor.java:
##
@@ -31,12 +31,8 @@
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.SloppyMath;
 
-/**
- * KNN search on top of 2D lat/lon indexed points.
- *
- * @lucene.experimental
- */
-class NearestNeighbor {
+/** KNN search on top of 2D lat/lon indexed points. */
+public class NearestNeighbor {

Review Comment:
   Can we keep it pkg-private if we have it in oal.document? This is especially 
important as we're promoting this class to core.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org