提升查詢
可以提高查詢以增加其相對於其他子查詢的分數。這是通過使用 BoostQuery 包裝它完成的
Query lessRelevantQuery = new TermQuery(new Term("fieldname", "ipsum"));
//Five times as interesting
Query highlyRelevantQuery = new BoostQuery(
new TermQuery(new Term("fieldname", "lorem")),
5.0f);
BooleanQuery query = new BooleanQuery.Builder()
.add(lessRelevantQuery, BooleanClause.Occur.SHOULD)
.add(highlyRelevantQuery, BooleanClause.Occur.SHOULD)
.build();