* @return a Weight that applies the predicate to the query.
* @throws IOException if IO issues occur.
*/
@Override
public Weight createWeight(final Searcher searcher) throws IOException {
final Weight weight = this.query.createWeight(searcher);
final Similarity similarity = this.query.getSimilarity(searcher);
return new Weight() {
private float value;
// pass these methods through to enclosed query's weight
@Override
public float getValue() {
return this.value;
}
@Override
public boolean scoresDocsOutOfOrder() {
return false;
}
public float sumOfSquaredWeights() throws IOException {
return weight.sumOfSquaredWeights() * getBoost() * getBoost();
}
@Override
public void normalize(final float v) {
weight.normalize(v * getBoost()); // incorporate boost
this.value = weight.getValue();
}
@Override
public Explanation explain(final IndexReader reader, final int i)
throws IOException {
Explanation inner = weight.explain(reader, i);
Bits predicate = PredicateQuery.this.predicate.get(reader);
if (predicate.get(i)) {
return inner;
} else {
Explanation result = new Explanation(0.0f,