LUCENE-9046: Fix wrong example in Javadoc of TermInSetQuery

Signed-off-by: Namgyu Kim <namgyu@apache.org>
This commit is contained in:
Namgyu Kim 2019-11-16 02:42:55 +09:00 committed by GitHub
parent 805305c410
commit d1163450b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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) {