use of org.apache.lucene.queries.function.docvalues.LongDocValues in project lucene-solr by apache.
the class TotalTermFreqValueSource method createWeight.
@Override
public void createWeight(Map context, IndexSearcher searcher) throws IOException {
long totalTermFreq = 0;
for (LeafReaderContext readerContext : searcher.getTopReaderContext().leaves()) {
long val = readerContext.reader().totalTermFreq(new Term(indexedField, indexedBytes));
if (val == -1) {
totalTermFreq = -1;
break;
} else {
totalTermFreq += val;
}
}
final long ttf = totalTermFreq;
context.put(this, new LongDocValues(this) {
@Override
public long longVal(int doc) {
return ttf;
}
});
}
Aggregations