lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <>
Subject QueryParser oddity with PrefixQuery
Date Sun, 25 Feb 2007 21:40:57 GMT
In certain cases, I use a modified QueryParser which does not allow "field:" 
syntax.  While testing variants of Prefix and Wildcard Query, I came across an 
oddity with getPrefixQuery().  The standard getPrefixQuery() (2.1) is given 
termStr without the trailing *, so the check

if (!allowLeadingWildcard && termStr.startsWith("*"))
   throw new ParseException("'*' not allowed as first character in PrefixQuery");

only triggers if you parse the String "**", in which case the PrefixQuery is 
then created with Term(field, "*"); whereas if you parse "*", getWildcardQuery() 
is called.

So it's not obvious that the test "termStr.startsWith("*"))" can ever occur, so 
this code seems redundant.

After Doron's latest patch, if 
you parse "**" it now calls getWildcardQuery().


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message