LUCENE-8216: improve error message when field weight is invalid

This commit is contained in:
Jim Ferenczi 2018-11-21 10:27:51 +01:00
parent fd96bc5ca6
commit 08dd681f0f
2 changed files with 2 additions and 2 deletions

View File

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

View File

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