Example usage for org.apache.lucene.search TopDocs merge

List of usage examples for org.apache.lucene.search TopDocs merge

Introduction

In this page you can find the example usage for org.apache.lucene.search TopDocs merge.

Prototype

public static TopDocs merge(int topN, TopDocs[] shardHits) 

Source Link

Document

Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by score.

Usage

From source file:com.yahoo.bard.webservice.data.dimension.impl.TimeLimitingCollectorManager.java

License:Apache License

@Override
public TopDocs reduce(Collection<AccessibleTimeLimitingCollector> collectors) throws IOException {
    TopDocs[] docs = collectors.stream().map(AccessibleTimeLimitingCollector::getWrappedCollector)
            .map(TopDocsCollector::topDocs).collect(Collectors.toList())
            .toArray(new TopDocs[collectors.size()]);

    return TopDocs.merge(perPage, docs);
}

From source file:org.elasticsearch.action.search.SearchPhaseControllerTests.java

License:Apache License

private ScoreDoc[] getTopShardDocs(AtomicArray<QuerySearchResultProvider> results) throws IOException {
    List<AtomicArray.Entry<QuerySearchResultProvider>> resultList = results.asList();
    TopDocs[] shardTopDocs = new TopDocs[resultList.size()];
    for (int i = 0; i < resultList.size(); i++) {
        shardTopDocs[i] = resultList.get(i).value.queryResult().topDocs();
    }// w  w  w . ja  v  a2  s  . co  m
    int topN = Math.min(results.get(0).queryResult().size(), getTotalQueryHits(results));
    return TopDocs.merge(topN, shardTopDocs).scoreDocs;
}

From source file:retriever.QuantizedVecSearcher.java

public List<DocVector> retrieveWithPivotedRelaxedWeightedQueries(DocVector qvec) throws Exception {
    List<TopDocs> topDocs = new ArrayList<>();

    HashSet<Integer> dimensionSet = new HashSet<>();
    for (int i = 0; i < qvec.numDimensions; i++)
        dimensionSet.add(i);//from w ww.ja  v  a  2s  .c o m

    // Iterate while there're more dimensions to explore...
    for (int i = 0; i < qvec.numDimensions && dimensionSet.size() > 0; i++) {

        // Explore a subspace and don't consider these dimenions further...
        TopDocs thisTopDocs = retrieveWithPivotedRelaxedWeightedQuery(qvec, i, dimensionSet);
        if (thisTopDocs != null)
            topDocs.add(thisTopDocs);

    }

    TopDocs[] topDocsArray = new TopDocs[topDocs.size()];
    TopDocs mergedTopDocs = TopDocs.merge(nwanted, topDocs.toArray(topDocsArray));

    return rerankByEuclideanDist(qvec, searcher, mergedTopDocs);
}