Search in sources :

Example 6 with ScoredResult

use of io.zulia.message.ZuliaQuery.ScoredResult in project zuliasearch by zuliaio.

the class QueryCombiner method createLastIndexResultMapWithPreviousLastResults.

private Map<String, ScoredResult[]> createLastIndexResultMapWithPreviousLastResults() {
    Map<String, ScoredResult[]> lastIndexResultMap = new HashMap<>();
    for (String indexName : indexToShardQueryResponseMap.keySet()) {
        int numberOfShards = indexToShardCount.get(indexName);
        lastIndexResultMap.put(indexName, new ScoredResult[numberOfShards]);
    }
    for (LastIndexResult lir : lastResult.getLastIndexResultList()) {
        ScoredResult[] lastForShardArr = lastIndexResultMap.get(lir.getIndexName());
        // initialize with last results
        for (ScoredResult sr : lir.getLastForShardList()) {
            lastForShardArr[sr.getShard()] = sr;
        }
    }
    return lastIndexResultMap;
}
Also used : LastIndexResult(io.zulia.message.ZuliaQuery.LastIndexResult) HashMap(java.util.HashMap) ScoredResult(io.zulia.message.ZuliaQuery.ScoredResult)

Example 7 with ScoredResult

use of io.zulia.message.ZuliaQuery.ScoredResult in project zuliasearch by zuliaio.

the class QueryCombiner method createLastResult.

private LastResult createLastResult(Map<String, ScoredResult[]> lastIndexResultMap) {
    LastResult.Builder newLastResultBuilder = LastResult.newBuilder();
    for (String indexName : lastIndexResultMap.keySet()) {
        ScoredResult[] lastForShardArr = lastIndexResultMap.get(indexName);
        int numberOfShards = indexToShardCount.get(indexName);
        List<ScoredResult> indexList = new ArrayList<>();
        for (int shard = 0; shard < numberOfShards; shard++) {
            if (lastForShardArr[shard] != null) {
                ScoredResult.Builder minimalSR = ScoredResult.newBuilder(lastForShardArr[shard]).clearUniqueId().clearIndexName().clearResultIndex().clearTimestamp().clearResultDocument();
                indexList.add(minimalSR.build());
            }
        }
        if (!indexList.isEmpty()) {
            LastIndexResult lastIndexResult = LastIndexResult.newBuilder().addAllLastForShard(indexList).setIndexName(indexName).build();
            newLastResultBuilder.addLastIndexResult(lastIndexResult);
        }
    }
    return newLastResultBuilder.build();
}
Also used : LastIndexResult(io.zulia.message.ZuliaQuery.LastIndexResult) ArrayList(java.util.ArrayList) LastResult(io.zulia.message.ZuliaQuery.LastResult) ScoredResult(io.zulia.message.ZuliaQuery.ScoredResult)

Aggregations

ScoredResult (io.zulia.message.ZuliaQuery.ScoredResult)7 LastIndexResult (io.zulia.message.ZuliaQuery.LastIndexResult)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LastResult (io.zulia.message.ZuliaQuery.LastResult)2 ShardQueryResponse (io.zulia.message.ZuliaQuery.ShardQueryResponse)2 Map (java.util.Map)2 Term (io.zulia.message.ZuliaBase.Term)1 ZuliaQuery (io.zulia.message.ZuliaQuery)1 AnalysisRequest (io.zulia.message.ZuliaQuery.AnalysisRequest)1 AnalysisResult (io.zulia.message.ZuliaQuery.AnalysisResult)1 CountRequest (io.zulia.message.ZuliaQuery.CountRequest)1 FacetGroup (io.zulia.message.ZuliaQuery.FacetGroup)1 FieldSort (io.zulia.message.ZuliaQuery.FieldSort)1 StatRequest (io.zulia.message.ZuliaQuery.StatRequest)1 InternalQueryResponse (io.zulia.message.ZuliaServiceOuterClass.InternalQueryResponse)1 QueryResponse (io.zulia.message.ZuliaServiceOuterClass.QueryResponse)1 ZuliaIndex (io.zulia.server.index.ZuliaIndex)1