mirror of https://github.com/apache/lucene.git
Add getter for SynonymQuery#field (#13077)
--------- Co-authored-by: Andrey Bozhko <abozhko@apple.com>
This commit is contained in:
parent
bf6f38665e
commit
6764a01805
|
@ -178,6 +178,8 @@ Other
|
||||||
|
|
||||||
* GITHUB#13001: Put Thread#sleep() on the list of forbidden APIs. (Shubham Chaudhary)
|
* GITHUB#13001: Put Thread#sleep() on the list of forbidden APIs. (Shubham Chaudhary)
|
||||||
|
|
||||||
|
* GITHUB#13077: Add public getter for SynonymQuery#field (Andrey Bozhko)
|
||||||
|
|
||||||
======================== Lucene 9.11.0 =======================
|
======================== Lucene 9.11.0 =======================
|
||||||
|
|
||||||
API Changes
|
API Changes
|
||||||
|
|
|
@ -115,10 +115,16 @@ public final class SynonymQuery extends Query {
|
||||||
this.field = Objects.requireNonNull(field);
|
this.field = Objects.requireNonNull(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the terms of this {@link SynonymQuery} */
|
||||||
public List<Term> getTerms() {
|
public List<Term> getTerms() {
|
||||||
return Arrays.stream(terms).map(t -> new Term(field, t.term)).toList();
|
return Arrays.stream(terms).map(t -> new Term(field, t.term)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the field name of this {@link SynonymQuery} */
|
||||||
|
public String getField() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(String field) {
|
public String toString(String field) {
|
||||||
StringBuilder builder = new StringBuilder("Synonym(");
|
StringBuilder builder = new StringBuilder("Synonym(");
|
||||||
|
|
|
@ -87,6 +87,12 @@ public class TestSynonymQuery extends LuceneTestCase {
|
||||||
new SynonymQuery.Builder("field2").addTerm(new Term("field2", "b"), 0.4f).build());
|
new SynonymQuery.Builder("field2").addTerm(new Term("field2", "b"), 0.4f).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetField() {
|
||||||
|
SynonymQuery query =
|
||||||
|
new SynonymQuery.Builder("field1").addTerm(new Term("field1", "a")).build();
|
||||||
|
assertEquals("field1", query.getField());
|
||||||
|
}
|
||||||
|
|
||||||
public void testBogusParams() {
|
public void testBogusParams() {
|
||||||
expectThrows(
|
expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
Loading…
Reference in New Issue