PhraseQuery requires that all terms exist in the field under study.- Yours
BooleanQuerydoes not require all terms.
This leads to the question of what is the difference between yours PhraseQueryand:
term1 = new TermQuery(new Term(...));
booleanQuery.add(term1, BooleanClause.Occur.MUST);
term2 = new TermQuery(new Term(...));
booleanQuery.add(term2, BooleanClause.Occur.MUST);
term3 = new TermQuery(new Term(...));
booleanQuery.add(term3, BooleanClause.Occur.MUST);
The difference here is that it PhraseQuerywill require the members to be in the correct order, as opposed to BooleanQuerythat which would not have any particular order requirement.
source
share