Java 类org.apache.lucene.search.DoubleValues 实例源码

项目:preDict    文件:LuceneWordSearch.java   
@Override
public void indexingDone() {
    try {
        spellChecker = new DirectSpellChecker();
        spellChecker.setMaxEdits(2);
        spellChecker.setAccuracy(0.1f);
        spellChecker.setMinPrefix(0);
        reader = DirectoryReader.open(writer);

        fuzzySuggester = new FuzzySuggester(directory, "", writer.getAnalyzer());
        Dictionary dict = new DocumentValueSourceDictionary(reader, WORD_FIELD, new LongValuesSource() {

            @Override
            public boolean needsScores() {
                return false;
            }

            @Override
            public LongValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
                return null;
            }
        });
        fuzzySuggester.build(dict);

        writer.close();
        searcher = new IndexSearcher(DirectoryReader.open(directory));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:elasticsearch-learning-to-rank    文件:DerivedExpressionQuery.java   
@Override
public Scorer scorer(LeafReaderContext context, Supplier<LtrRanker.FeatureVector> vectorSupplier) throws IOException {
    Bindings bindings = new Bindings(){
        @Override
        public DoubleValuesSource getDoubleValuesSource(String name) {
            return new FVDoubleValuesSource(vectorSupplier, features.featureOrdinal(name));
        }
    };

    DocIdSetIterator iterator = DocIdSetIterator.all(context.reader().maxDoc());
    DoubleValuesSource src = expression.getDoubleValuesSource(bindings);
    DoubleValues values = src.getValues(context, null);

    return new DValScorer(this, iterator, values);
}
项目:elasticsearch-learning-to-rank    文件:DerivedExpressionQuery.java   
@Override
public Explanation explain(LeafReaderContext context, LtrRanker.FeatureVector vector, int doc) throws IOException {
    Bindings bindings = new Bindings(){
        @Override
        public DoubleValuesSource getDoubleValuesSource(String name) {
            return new FVDoubleValuesSource(() -> vector, features.featureOrdinal(name));
        }
    };

    DoubleValuesSource src = expression.getDoubleValuesSource(bindings);
    DoubleValues values = src.getValues(context, null);
    values.advanceExact(doc);
    return Explanation.match((float) values.doubleValue(), "Evaluation of derived expression: " + expression.sourceText);
}
项目:elasticsearch-learning-to-rank    文件:DerivedExpressionQuery.java   
@Override
public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
    return new DoubleValues() {
        @Override
        public double doubleValue() throws IOException {
            assert vectorSupplier.get() != null;
            return vectorSupplier.get().getFeatureScore(ordinal);
        }

        @Override
        public boolean advanceExact(int doc) throws IOException {
            return true;
        }
    };
}
项目:elasticsearch_my    文件:ReplaceableConstDoubleValueSource.java   
@Override
public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
    return fv;
}
项目:elasticsearch-learning-to-rank    文件:DerivedExpressionQuery.java   
DValScorer(Weight weight, DocIdSetIterator iterator, DoubleValues values) {
    super(weight);
    this.iterator = iterator;
    this.values = values;
}