Skip to content

Apache Lucene open-source search software

Out of boundary in CombinedFieldQuery#addTerm (#12046)

Lu Xugang19cc6cdf6671
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ba9386f8a5c..7b9d5b2acf3 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -220,6 +220,8 @@ Bug Fixes
* GITHUB#12058: Fix detection of Hotspot in TestRamUsageEstimator so it works with OpenJ9.
(Uwe Schindler)
+* GITHUB#12046: Out of boundary in CombinedFieldQuery#addTerm. (Lu Xugang)
+
Optimizations
---------------------
* GITHUB#11738: Optimize MultiTermQueryConstantScoreWrapper when a term is present that matches all
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
index be59acae655..08bb24a846c 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
@@ -127,7 +127,7 @@ public final class CombinedFieldQuery extends Query implements Accountable {
/** Adds a term to this builder. */
public Builder addTerm(BytesRef term) {
- if (termsSet.size() > IndexSearcher.getMaxClauseCount()) {
+ if (termsSet.size() >= IndexSearcher.getMaxClauseCount()) {
throw new IndexSearcher.TooManyClauses();
}
termsSet.add(term);