Search in sources :

Example 1 with QueryCombiner

use of io.zulia.server.search.QueryCombiner in project zuliasearch by zuliaio.

the class QueryRequestFederator method getResponse.

public QueryResponse getResponse(QueryRequest request) throws Exception {
    long queryId = queryNumber.getAndIncrement();
    long start = System.currentTimeMillis();
    String queryJson = JsonFormat.printer().print(request);
    LOG.info("Running id <" + queryId + "> query <" + queryJson + ">");
    List<InternalQueryResponse> results = send(request);
    QueryCombiner queryCombiner = new QueryCombiner(indexes, request, results);
    QueryResponse qr = queryCombiner.getQueryResponse();
    if (!queryCombiner.isShort()) {
        long end = System.currentTimeMillis();
        LOG.info("Finished query id <" + queryId + "> in " + (end - start) + "ms");
        return qr;
    } else {
        if (!request.getFetchFull()) {
            QueryRequest newRequest = request.toBuilder().setFetchFull(true).build();
            long end = System.currentTimeMillis();
            LOG.info("Finished query id <" + queryId + "> in " + (end - start) + "ms");
            return getResponse(newRequest);
        }
        throw new Exception("Full fetch request is short");
    }
}
Also used : InternalQueryResponse(io.zulia.message.ZuliaServiceOuterClass.InternalQueryResponse) InternalQueryRequest(io.zulia.message.ZuliaServiceOuterClass.InternalQueryRequest) QueryRequest(io.zulia.message.ZuliaServiceOuterClass.QueryRequest) QueryResponse(io.zulia.message.ZuliaServiceOuterClass.QueryResponse) InternalQueryResponse(io.zulia.message.ZuliaServiceOuterClass.InternalQueryResponse) QueryCombiner(io.zulia.server.search.QueryCombiner) IOException(java.io.IOException)

Aggregations

InternalQueryRequest (io.zulia.message.ZuliaServiceOuterClass.InternalQueryRequest)1 InternalQueryResponse (io.zulia.message.ZuliaServiceOuterClass.InternalQueryResponse)1 QueryRequest (io.zulia.message.ZuliaServiceOuterClass.QueryRequest)1 QueryResponse (io.zulia.message.ZuliaServiceOuterClass.QueryResponse)1 QueryCombiner (io.zulia.server.search.QueryCombiner)1 IOException (java.io.IOException)1