Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-9046: Fix wrong example in Javadoc of TermInSetQuery

Namgyu Kimd1163450b6a9
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 354afb362ad..f752a5df4dc 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -127,6 +127,8 @@ Other
* LUCENE-8746: Refactor EdgeTree - Introduce a Component tree that represents the tree of components (e.g polygons).
Edge tree is now just a tree of edges. (Ignacio Vera)
+* LUCENE-9046: Fix wrong example in Javadoc of TermInSetQuery (Namgyu Kim)
+
Build
* Upgrade forbiddenapis to version 2.7; upgrade Groovy to 2.4.17. (Uwe Schindler)
diff --git a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
index 6375c7a78b4..acdd36efeb6 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
@@ -51,7 +51,7 @@ import org.apache.lucene.util.RamUsageEstimator;
* <p>For instance in the following example, both {@code q1} and {@code q2}
* would yield the same scores:
* <pre class="prettyprint">
- * Query q1 = new TermInSetQuery(new Term("field", "foo"), new Term("field", "bar"));
+ * Query q1 = new TermInSetQuery("field", new BytesRef("foo"), new BytesRef("bar"));
*
* BooleanQuery bq = new BooleanQuery();
* bq.add(new TermQuery(new Term("field", "foo")), Occur.SHOULD);
@@ -78,7 +78,7 @@ public class TermInSetQuery extends Query implements Accountable {
* Creates a new {@link TermInSetQuery} from the given collection of terms.
*/
public TermInSetQuery(String field, Collection<BytesRef> terms) {
- BytesRef[] sortedTerms = terms.toArray(new BytesRef[terms.size()]);
+ BytesRef[] sortedTerms = terms.toArray(new BytesRef[0]);
// already sorted if we are a SortedSet with natural order
boolean sorted = terms instanceof SortedSet && ((SortedSet<BytesRef>)terms).comparator() == null;
if (!sorted) {