mirror of https://github.com/apache/lucene.git
LUCENE-8094: improve TermInSetQuery.toString
This commit is contained in:
parent
f354a278f8
commit
1b201d04d7
|
@ -97,6 +97,8 @@ Improvements
|
|||
|
||||
* LUCENE-8093: TrimFilterFactory implements MultiTermAwareComponent (Alan Woodward)
|
||||
|
||||
* LUCENE-8094: TermInSetQuery.toString now returns "field:(A B C)" (Mike McCandless)
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* LUCENE-8077: Fixed bug in how CheckIndex verifies doc-value iterators.
|
||||
|
|
|
@ -148,15 +148,19 @@ public class TermInSetQuery extends Query implements Accountable {
|
|||
@Override
|
||||
public String toString(String defaultField) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean first = true;
|
||||
builder.append(field);
|
||||
builder.append(":(");
|
||||
|
||||
TermIterator iterator = termData.iterator();
|
||||
boolean first = true;
|
||||
for (BytesRef term = iterator.next(); term != null; term = iterator.next()) {
|
||||
if (!first) {
|
||||
builder.append(' ');
|
||||
}
|
||||
first = false;
|
||||
builder.append(new Term(iterator.field(), term).toString());
|
||||
builder.append(Term.toString(term));
|
||||
}
|
||||
builder.append(')');
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ public class TermInSetQueryTest extends LuceneTestCase {
|
|||
public void testToString() {
|
||||
TermInSetQuery termsQuery = new TermInSetQuery("field1",
|
||||
new BytesRef("a"), new BytesRef("b"), new BytesRef("c"));
|
||||
assertEquals("field1:a field1:b field1:c", termsQuery.toString());
|
||||
assertEquals("field1:(a b c)", termsQuery.toString());
|
||||
}
|
||||
|
||||
public void testDedup() {
|
||||
|
@ -285,7 +285,7 @@ public class TermInSetQueryTest extends LuceneTestCase {
|
|||
|
||||
public void testBinaryToString() {
|
||||
TermInSetQuery query = new TermInSetQuery("field", new BytesRef(new byte[] { (byte) 0xff, (byte) 0xfe }));
|
||||
assertEquals("field:[ff fe]", query.toString());
|
||||
assertEquals("field:([ff fe])", query.toString());
|
||||
}
|
||||
|
||||
public void testIsConsideredCostlyByQueryCache() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue