lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Naber <>
Subject Re: MultiPhrase search
Date Tue, 26 Aug 2008 17:19:43 GMT
On Dienstag, 26. August 2008, Andre Rubin wrote:

> Now I was the one who didn't follow: How do I add a query to an existing
> query?

Something like this should work:

BooleanQuery bq = new BooleanQuery();
PrefixQuery pq = new PrefixQuery(...);
bq.add(pq, BooleanClause.Occur.MUST);
TermQuery tq = new TermQuery(new Term("type", "sequence"));
bq.add(tq, BooleanClause.Occur.MUST);

bq is now the query you can use for searching. BooleanClause.Occur.MUST 
basically means "AND". So unless you want your users to access the 
features of Lucene's QueryParser (e.g. AND, OR, NOT, fuzzy queries etc) 
there's no need to use it.



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

View raw message