@Override
    public final Result search(Query query, Execution execution) {
        int tries = 0;

        Hasher.NodeList<T> nodes = getHasher().getNodes();

        if (nodes.getNodeCount() == 0)
            return search(query, execution, ErrorMessage
                    .createNoBackendsInService("No nodes in service in " + this + " (" + monitor.nodeMonitors().size()
                                               + " was configured, none is responding)"));

        int code = query.hashCode();
        Result result;
        T connection = getFirstConnection(nodes, code, tries, query);
        do {
            // The loop is in case there are other searchers available able to produce results
            if (connection == null)
                return search(query,
                              execution,
                              ErrorMessage.createNoBackendsInService("No in node could handle " + query +
                                                                     " according to " + hasher + " in " + this));
            if (timedOut(query))
                return new Result(query, ErrorMessage.createTimeout("No time left for searching"));

            if (query.getTrace().getLevel() >= 8)
                query.trace("Trying " + connection, false, 8);

            result = robustSearch(query, execution, connection);

            if ( ! shouldRetry(query, result))
                return result;

            if (query.getTrace().getLevel() >= 6)
                query.trace("Error from connection " + connection + " : " + result.hits().getError(), false, 6);

            if (result.hits().getError().getCode() == Error.TIMEOUT.code)
                return result; // Retry is unlikely to help

            log(Level.FINER, "No result, checking for timeout.");
            tries++;
            connection = nodes.select(code, tries);
        } while (tries < nodes.getNodeCount());

        // only error result gets returned here.
        return result;

    }
Pings this connection. Pings may be sent "out of band" at any time by the
monitoring subsystem to determine the status of this connection. If the
ping fails, it is ok both to set an error in the pong or to throw an
exception.
container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java