Tutorial by Examples

BooleanQuery is used to combine other queries. They can be combined using three BooleanClause.Occur parameters: BooleanClause.Occur.MUST - The subquery must be matched. BooleanClause.Occur.SHOULD - The subquery may not be matched, but will be scored more highly if it is. If there are no MUST...
PhraseQuery is used to search for a sequence of terms. The following matches the phrase "Hello World" (after being indexed with StandardAnalyzer) Query query = new PhraseQuery.Builder() .add(new Term("text", "hello")) .add(new Term("text"...
This combines queries such that the best (that is, highest-scoring) match of it's subqueries contributes to the final score. List<Query> disjuncts = new ArrayList<Query>(); disjuncts.add(new TermQuery(new Term("fieldname", "hello"))); disjuncts.add(new TermQuery(...
A query can be boosted to increase it's score relative to other subqueries. This is done by wrapping it with a BoostQuery Query lessRelevantQuery = new TermQuery(new Term("fieldname", "ipsum")); //Five times as interesting Query highlyRelevantQuery = new BoostQuery( ...

Page 1 of 1