Here you go: import junit.framework.TestCase;
import org.apache.lucene.analysis.WhitespaceAnalyzer; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.WildcardQuery; public class WildcardQueryTest extends TestCase { private QueryParser qp; protected void setUp() throws Exception { super.setUp(); WhitespaceAnalyzer analyzer = new WhitespaceAnalyzer(); qp = new QueryParser("name", analyzer); qp.setAllowLeadingWildcard(true); } public void testContainsQuery() throws Exception { // Trailing wildcard parses to PrefixQuery String predicate = "name:Hom*"; Query q = qp.parse(predicate); assertEquals(predicate + " parsed to PrefixQuery", PrefixQuery.class, q.getClass()); // Leading wildcard parses to WildcardQuery predicate = "name:*omer"; q = qp.parse(predicate); assertEquals(predicate + " parsed to WildcardQuery", WildcardQuery.class, q.getClass()); // Middle wildcard parses to WildcardQuery predicate = "name:H*r"; q = qp.parse(predicate); assertEquals(predicate + " parsed to WildcardQuery", WildcardQuery.class, q.getClass()); // Leading and trailing wildcards parse to PrefixQuery predicate = "name:*om*"; q = qp.parse(predicate); assertEquals(predicate + " parsed to PrefixQuery", PrefixQuery.class, q.getClass()); // Leading and middle wildcards parse to WildcardQuery predicate = "name:*ar*e"; q = qp.parse(predicate); assertEquals(predicate + " parsed to WildcardQuery", WildcardQuery.class, q.getClass()); // Middle and trailing wildcards parse to WildcardQuery predicate = "name:ar*e*"; q = qp.parse(predicate); assertEquals(predicate + " parsed to WildcardQuery", WildcardQuery.class, q.getClass()); } protected void tearDown() throws Exception { super.tearDown(); } } hossman_lucene wrote: > > > : I'm using 2.1.0 and I'm calling setAllowLeadingWildcard(true) first on > my > : QueryParser instance. I'm using a PerFieldAnalyzerWrapper where the > field of > : interest uses the WhiteSpaceAnalyzer. > > could you send some code demonstrating the probelm you areseeing? ideally > in the form of a small self contained JUnit test. > > > > > -Hoss > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/%22Contains%22-query-parsed-to-PrefixQuery-tf3904234.html#a11071503 Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]