提升查询

可以提高查询以增加其相对于其他子查询的分数。这是通过使用 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();