Search in sources :

Example 6 with LongDocValues

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;
        }
    });
}
Also used : LeafReaderContext(org.apache.lucene.index.LeafReaderContext) Term(org.apache.lucene.index.Term) LongDocValues(org.apache.lucene.queries.function.docvalues.LongDocValues)

Aggregations

LongDocValues (org.apache.lucene.queries.function.docvalues.LongDocValues)6 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)3 NumericDocValues (org.apache.lucene.index.NumericDocValues)2 MutableValueDate (org.apache.lucene.util.mutable.MutableValueDate)2 MutableValueLong (org.apache.lucene.util.mutable.MutableValueLong)2 Map (java.util.Map)1 SortedDocValues (org.apache.lucene.index.SortedDocValues)1 SortedSetDocValues (org.apache.lucene.index.SortedSetDocValues)1 Term (org.apache.lucene.index.Term)1 Terms (org.apache.lucene.index.Terms)1 FunctionValues (org.apache.lucene.queries.function.FunctionValues)1 SortedSetFieldSource (org.apache.lucene.queries.function.valuesource.SortedSetFieldSource)1 BytesRef (org.apache.lucene.util.BytesRef)1