Throw ParseException instead of IllegalArgumentException

in case of illegal value for FuzzyQuery minimum similarity
parameter.


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christoph Goller 2004-09-15 13:37:26 +00:00
parent a6fad246dd
commit 99d5aeee4a
2 changed files with 6 additions and 0 deletions

View File

@ -706,6 +706,9 @@ public class QueryParser implements QueryParserConstants {
try {
fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
} catch (Exception ignored) { }
if(fms < 0.0f || fms > 1.0f){
{if (true) throw new ParseException("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !");}
}
q = getFuzzyQuery(field, termImage, fms);
} else {
q = getFieldQuery(field, termImage);

View File

@ -684,6 +684,9 @@ Query Term(String field) : {
try {
fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
} catch (Exception ignored) { }
if(fms < 0.0f || fms > 1.0f){
throw new ParseException("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !");
}
q = getFuzzyQuery(field, termImage, fms);
} else {
q = getFieldQuery(field, termImage);