use of org.apache.lucene.search.FilterScorer in project lucene-solr by apache.
the class TestJoinUtil method numericDocValuesScoreQuery.
// FunctionQuery would be helpful, but join module doesn't depend on queries module.
static Query numericDocValuesScoreQuery(final String field) {
return new Query() {
private final Query fieldQuery = new FieldValueQuery(field);
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
Weight fieldWeight = fieldQuery.createWeight(searcher, false, boost);
return new Weight(this) {
@Override
public void extractTerms(Set<Term> terms) {
}
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
return null;
}
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
Scorer fieldScorer = fieldWeight.scorer(context);
if (fieldScorer == null) {
return null;
}
NumericDocValues price = context.reader().getNumericDocValues(field);
return new FilterScorer(fieldScorer, this) {
@Override
public float score() throws IOException {
assertEquals(in.docID(), price.advance(in.docID()));
return (float) price.longValue();
}
};
}
};
}
@Override
public String toString(String field) {
return fieldQuery.toString(field);
}
@Override
public boolean equals(Object o) {
return o == this;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
};
}
Aggregations