You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/05/17 16:55:58 UTC

[GitHub] [lucene] shahrs87 opened a new pull request, #897: LUCENE-10266 Move nearest-neighbor search on points to core

shahrs87 opened a new pull request, #897:
URL: https://github.com/apache/lucene/pull/897

   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Lucene:
   
   * https://issues.apache.org/jira/projects/LUCENE
   
   You will need to create an account in Jira in order to create an issue.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * LUCENE-####: <short description of problem or changes>
   
   LUCENE must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   Please provide a short description of the changes you're making with this pull request.
   
   # Solution
   
   Please provide a short description of the approach taken to implement your solution.
   
   # Tests
   
   Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/lucene/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability.
   - [ ] I have given Lucene maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [ ] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
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.
+   *
+   * <p>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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on PR #897:
URL: https://github.com/apache/lucene/pull/897#issuecomment-1132091362

   @jpountz  @iverase @mikemccand  Can you guys please help me review this patch ? Tagging Ignacio and Michael since you showed interest in the corresponding jira. Thank you. 


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
jpountz commented on PR #897:
URL: https://github.com/apache/lucene/pull/897#issuecomment-1154147639

   Thanks @shahrs87 !


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on PR #897:
URL: https://github.com/apache/lucene/pull/897#issuecomment-1149268621

   @jpountz Addressed all of your previous comments. Please review again. Thank you.


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on PR #897:
URL: https://github.com/apache/lucene/pull/897#issuecomment-1134875992

   @jpountz  Thank you for the feedback. I have addressed your comments in the latest revision. I have one question. To make changes in the CHANGES.txt file, will this change go in `API changes` section or `Other`. Please advise.


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on code in PR #897:
URL: https://github.com/apache/lucene/pull/897#discussion_r879640507


##########
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.
+   *
+   * <p>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:
   Removed in the latest revision.



-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
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.
+   *
+   * <p>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.
+   *
+   * <p>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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on PR #897:
URL: https://github.com/apache/lucene/pull/897#issuecomment-1129107476

   @jpountz I have created this PR as per your suggestion in LUCENE-10266 jira. I have made the following assumptions. Please correct me if needed.
   1. I have deleted LatLonPointPrototypeQueries class since there is no other sandobx query in that class. Should I keep the empty class ?
   2. I see we have FloatPointNearestNeighbor implementation in sandbox which is similar to NearestNeighbor. Do I need to remove FloatPointNearestNeighbor from sandbox and move it to lucene/core ?
   3. I have added this change to API Changes section in CHANGES.txt Please correct if it belongs somewhere else.
   
   Thank you.


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on code in PR #897:
URL: https://github.com/apache/lucene/pull/897#discussion_r879640718


##########
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:
   Yes. Changed in the latest revision.



-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
jpountz merged PR #897:
URL: https://github.com/apache/lucene/pull/897


-- 
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-unsubscribe@lucene.apache.org

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


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


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

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on PR #897:
URL: https://github.com/apache/lucene/pull/897#issuecomment-1154177806

   Thank you @jpountz for the review and merge. :)


-- 
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-unsubscribe@lucene.apache.org

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


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