mirror of https://github.com/apache/lucene.git
LUCENE-8216: improve error message when field weight is invalid
This commit is contained in:
parent
fd96bc5ca6
commit
08dd681f0f
|
@ -94,7 +94,7 @@ public final class BM25FQuery extends Query {
|
|||
*/
|
||||
public Builder addField(String field, float weight) {
|
||||
if (weight < 1) {
|
||||
throw new IllegalArgumentException("weight must be greater than 1");
|
||||
throw new IllegalArgumentException("weight must be greater or equal to 1");
|
||||
}
|
||||
fieldAndWeights.put(field, new FieldAndWeight(field, weight));
|
||||
return this;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TestBM25FQuery extends LuceneTestCase {
|
|||
BM25FQuery.Builder builder = new BM25FQuery.Builder();
|
||||
IllegalArgumentException exc =
|
||||
expectThrows(IllegalArgumentException.class, () -> builder.addField("foo", 0.5f));
|
||||
assertEquals(exc.getMessage(), "weight must be greater than 1");
|
||||
assertEquals(exc.getMessage(), "weight must be greater or equal to 1");
|
||||
}
|
||||
|
||||
public void testRewrite() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue