当前位置: 首页>>代码示例>>Java>>正文


Java DocIdSetIterator.all方法代码示例

本文整理汇总了Java中org.apache.lucene.search.DocIdSetIterator.all方法的典型用法代码示例。如果您正苦于以下问题:Java DocIdSetIterator.all方法的具体用法?Java DocIdSetIterator.all怎么用?Java DocIdSetIterator.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.search.DocIdSetIterator的用法示例。


在下文中一共展示了DocIdSetIterator.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createWeight

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
    if (!needsScores) {
        // If scores are not needed simply return a constant score on all docs
        return new ConstantScoreWeight(this) {
            @Override
            public Scorer scorer(LeafReaderContext context) throws IOException {
                return new ConstantScoreScorer(this, score(), DocIdSetIterator.all(context.reader().maxDoc()));
            }
        };
    }
    List<Weight> weights = new ArrayList<>(queries.size());
    for (Query q : queries) {
        weights.add(searcher.createWeight(q, needsScores));
    }
    return new RankerWeight(weights);
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:18,代码来源:RankerQuery.java

示例2: iterateAllDocs

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
private DocIdSetIterator iterateAllDocs()
{
    IndexReader reader = searcher.getIndexReader();
    final Bits liveDocs = MultiFields.getLiveDocs( reader );
    final DocIdSetIterator allDocs = DocIdSetIterator.all( reader.maxDoc() );
    if ( liveDocs == null )
    {
        return allDocs;
    }

    return new FilteredDocIdSetIterator( allDocs )
    {
        @Override
        protected boolean match( int doc )
        {
            return liveDocs.get( doc );
        }
    };
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:20,代码来源:LuceneAllDocumentsReader.java

示例3: createWeight

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores)
        throws IOException {
    return new ConstantScoreWeight(this) {
        @Override
        public Scorer scorer(LeafReaderContext context) throws IOException {
            return new ConstantScoreScorer(this, score(), DocIdSetIterator.all(context.reader().maxDoc()));
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:IndicesQueryCacheTests.java

示例4: createWeight

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
    if (!needsScores) {
        // If scores are not needed simply return a constant score on all docs
        return new ConstantScoreWeight(this) {
            @Override
            public Scorer scorer(LeafReaderContext context) throws IOException {
                return new ConstantScoreScorer(this, score(), DocIdSetIterator.all(context.reader().maxDoc()));
            }
        };
    }

    return new FVWeight(this);
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:15,代码来源:DerivedExpressionQuery.java

示例5: scorer

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@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);
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:16,代码来源:DerivedExpressionQuery.java

示例6: scorer

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
private static Scorer scorer(int maxDoc, final int[] docs, final float[] scores, final boolean twoPhase) {
    final DocIdSetIterator iterator = twoPhase ? DocIdSetIterator.all(maxDoc) : iterator(docs);
    return new Scorer(null) {
        public DocIdSetIterator iterator() {
            if (twoPhase) {
                return TwoPhaseIterator.asDocIdSetIterator(twoPhaseIterator());
            } else {
                return iterator;
            }
        }

        public TwoPhaseIterator twoPhaseIterator() {
            if (twoPhase) {
                return new TwoPhaseIterator(iterator) {
                    
                    @Override
                    public boolean matches() throws IOException {
                        return Arrays.binarySearch(docs, iterator.docID()) >= 0;
                    }
                    
                    @Override
                    public float matchCost() {
                        return 10;
                    }
                };
            } else {
                return null;
            }
        }

        @Override
        public int docID() {
            return iterator.docID();
        }

        @Override
        public float score() throws IOException {
            final int idx = Arrays.binarySearch(docs, docID());
            return scores[idx];
        }

        @Override
        public int freq() throws IOException {
            return 1;
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:48,代码来源:MinScoreScorerTests.java

示例7: createWeight

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
    final Weight boundingBoxWeight;
    if (boundingBoxFilter != null) {
        boundingBoxWeight = searcher.createNormalizedWeight(boundingBoxFilter, false);
    } else {
        boundingBoxWeight = null;
    }
    return new ConstantScoreWeight(this) {
        @Override
        public Scorer scorer(LeafReaderContext context) throws IOException {
            final DocIdSetIterator approximation;
            if (boundingBoxWeight != null) {
                Scorer s = boundingBoxWeight.scorer(context);
                if (s == null) {
                    // if the approximation does not match anything, we're done
                    return null;
                }
                approximation = s.iterator();
            } else {
                approximation = DocIdSetIterator.all(context.reader().maxDoc());
            }
            final MultiGeoPointValues values = indexFieldData.load(context).getGeoPointValues();
            final TwoPhaseIterator twoPhaseIterator = new TwoPhaseIterator(approximation) {
                @Override
                public boolean matches() throws IOException {
                    final int doc = approximation.docID();
                    values.setDocument(doc);
                    final int length = values.count();
                    for (int i = 0; i < length; i++) {
                        GeoPoint point = values.valueAt(i);
                        if (distanceBoundingCheck.isWithin(point.lat(), point.lon())) {
                            double d = fixedSourceDistance.calculate(point.lat(), point.lon());
                            if (d >= inclusiveLowerPoint && d <= inclusiveUpperPoint) {
                                return true;
                            }
                        }
                    }
                    return false;
                }

                @Override
                public float matchCost() {
                    if (distanceBoundingCheck == GeoDistance.ALWAYS_INSTANCE) {
                        return 0.0f;
                    } else {
                        // TODO: is this right (up to 4 comparisons from GeoDistance.SimpleDistanceBoundingCheck)?
                        return 4.0f;
                    }
                }
            };
            return new ConstantScoreScorer(this, score(), twoPhaseIterator);
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:56,代码来源:GeoDistanceRangeQuery.java

示例8: NoopScorer

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
/**
 * Constructs a Scorer
 *
 * @param weight The scorers <code>Weight</code>.
 */
public NoopScorer(Weight weight, int maxDocs) {
    super(weight);
    _noopIter = DocIdSetIterator.all(maxDocs);

}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:11,代码来源:NoopScorer.java


注:本文中的org.apache.lucene.search.DocIdSetIterator.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。