You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2025/01/18 10:41:31 UTC
(lucene) branch main updated: Fix negative cost in some IntersectVisitor implementations after #14138 (#14150)
This is an automated email from the ASF dual-hosted git repository.
ivera pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new dce24c86217 Fix negative cost in some IntersectVisitor implementations after #14138 (#14150)
dce24c86217 is described below
commit dce24c8621748d51954c4845eab7626dae166db9
Author: Ignacio Vera <iv...@apache.org>
AuthorDate: Sat Jan 18 11:41:25 2025 +0100
Fix negative cost in some IntersectVisitor implementations after #14138 (#14150)
Introduced in #14138, we need to prevent negative scores when subtracting the added hits in LatLonPointDistanceQuery, SpatialQuery and PointRangeQuery.
---
.../src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java | 2 +-
lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java | 2 +-
lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
index 9cebb8e7301..4e816ffa625 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
@@ -280,7 +280,7 @@ final class LatLonPointDistanceQuery extends Query {
for (int i = 0; i < ref.length; i++) {
result.clear(ref.ints[ref.offset + i]);
}
- cost[0] = -ref.length;
+ cost[0] = Math.max(0, cost[0] - ref.length);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java b/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
index cc233f89948..4caf0652686 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
@@ -677,7 +677,7 @@ abstract class SpatialQuery extends Query {
for (int i = 0; i < ref.length; i++) {
result.clear(ref.ints[ref.offset + i]);
}
- cost[0] -= ref.length;
+ cost[0] = Math.max(0, cost[0] - ref.length);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
index e5d956e8d1e..97ae34713f8 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
@@ -233,7 +233,7 @@ public abstract class PointRangeQuery extends Query {
for (int i = ref.offset; i < ref.offset + ref.length; i++) {
result.clear(ref.ints[i]);
}
- cost[0] -= ref.length;
+ cost[0] = Math.max(0, cost[0] - ref.length);
}
@Override