Hi,
I am trying to implement a "progressive search" with Lucene. What I mean is that
something like what Google does: you type a few letters and google searches for
matches as you type. The more letters you enter, the more precise your search
becomes.
I decided to use a prefix query because otherwise, I need to have complete words
in order for multiword queries to work.
I am using Compass as my Lucene frontend.
My query looks like this:
BooleanQuery bq = new BooleanQuery();
// The last word is a prefix
PrefixQuery pq =
new PrefixQuery(new Term("searchField", words[words.length - 1]));
bq.add(pq, BooleanClause.Occur.MUST);
// All others are normal terms
for (int i = 0; i <= (words.length - 2); i++) {
TermQuery tq = new TermQuery(new Term("searchField", words[i]));
bq.add(tq, BooleanClause.Occur.MUST);
}
The problem I have is that if I specify "little fa" as search terms, Lucene will
match
The little fairy
but also
Farris little
The little pig farmer
Chicken Little: looking far ahead
(each line is the content of a separate document)
I only want the first type of matches.
What should I be doing instead?
Thanks,
L
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]