From 99d5aeee4af570f3d9504f913055b2967b148a16 Mon Sep 17 00:00:00 2001 From: Christoph Goller Date: Wed, 15 Sep 2004 13:37:26 +0000 Subject: [PATCH] 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 --- src/java/org/apache/lucene/queryParser/QueryParser.java | 3 +++ src/java/org/apache/lucene/queryParser/QueryParser.jj | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/java/org/apache/lucene/queryParser/QueryParser.java b/src/java/org/apache/lucene/queryParser/QueryParser.java index 04367a7bbd5..1e4c2ec6f8c 100644 --- a/src/java/org/apache/lucene/queryParser/QueryParser.java +++ b/src/java/org/apache/lucene/queryParser/QueryParser.java @@ -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); diff --git a/src/java/org/apache/lucene/queryParser/QueryParser.jj b/src/java/org/apache/lucene/queryParser/QueryParser.jj index 519b8306a1f..40f0ea04c21 100644 --- a/src/java/org/apache/lucene/queryParser/QueryParser.jj +++ b/src/java/org/apache/lucene/queryParser/QueryParser.jj @@ -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);