You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2023/06/26 12:28:39 UTC
[lucene] branch branch_9x updated: Fix edge case in TestJoinUtil
This is an automated email from the ASF dual-hosted git repository.
romseygeek pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new b6c55f90c2f Fix edge case in TestJoinUtil
b6c55f90c2f is described below
commit b6c55f90c2fef4c69b507a788e78304dadf336b6
Author: Alan Woodward <ro...@apache.org>
AuthorDate: Mon Jun 26 13:16:55 2023 +0100
Fix edge case in TestJoinUtil
TestJoinUtil.checkBoost() needs to check to see if there are
any results to validate, otherwise we can get an array-out-of-bounds
exception
---
lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
index 1ae412010e3..ae55587edcb 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
@@ -540,6 +540,7 @@ public class TestJoinUtil extends LuceneTestCase {
String id = searcher.storedFields().document(scoreDoc.doc).get("id");
assertEquals(lowestScoresPerParent.get(id), scoreDoc.score, 0f);
}
+ checkBoost(joinQuery, searcher);
joinQuery =
JoinUtil.createJoinQuery(
@@ -551,6 +552,7 @@ public class TestJoinUtil extends LuceneTestCase {
String id = searcher.storedFields().document(scoreDoc.doc).get("id");
assertEquals(highestScoresPerParent.get(id), scoreDoc.score, 0f);
}
+ checkBoost(joinQuery, searcher);
searcher.getIndexReader().close();
dir.close();
@@ -1052,6 +1054,9 @@ public class TestJoinUtil extends LuceneTestCase {
private void checkBoost(Query query, IndexSearcher searcher) throws IOException {
TopDocs result = searcher.search(query, 10);
+ if (result.scoreDocs.length == 0) {
+ return;
+ }
Query boostedQuery = new BoostQuery(query, 10);
TopDocs boostedResult = searcher.search(boostedQuery, 10);
assertEquals(result.scoreDocs[0].score * 10, boostedResult.scoreDocs[0].score, 0.000001f);