lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rapthor <>
Subject AND query in SHOULD
Date Thu, 22 Nov 2007 11:07:16 GMT


I want to realize a search that finds the exact phrase I provide. If the
word I am searching for is "green tree", I do NOT want to get results for
"green" or "tree", but only results for "green tree" within the given field.

This doesn't work so far for me. When providing a word that contains white
spaces, Lucene does not give any results at all even though there are
documents with the terms within the word in that order. This is what my
source looks:

BooleanQuery bq = new BooleanQuery();
for (String word : words) {
	for (String field : fields) {
		bq.add(new TermQuery(new Term(field, word)), Occur.SHOULD);
Hits hits =;

What's wrong? How to achieve the functionality?

Thanks in advance.
View this message in context:
Sent from the Lucene - Java Users mailing list archive at

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

View raw message