Search in sources :

Example 1 with UnresolvedSearchChainException

use of com.yahoo.search.federation.sourceref.UnresolvedSearchChainException in project vespa by vespa-engine.

the class FederationSearcher method search.

@Override
public Result search(Query query, Execution execution) {
    Result mergedResults = execution.search(query);
    Results<SearchChainInvocationSpec, UnresolvedSearchChainException> targets = getTargets(query.getModel().getSources(), query.properties(), execution.context().getIndexFacts());
    warnIfUnresolvedSearchChains(targets.errors(), mergedResults.hits());
    Collection<SearchChainInvocationSpec> prunedTargets = pruneTargetsWithoutDocumentTypes(query.getModel().getRestrict(), targets.data());
    Results<Target, ErrorMessage> regularTargetHandlers = resolveSearchChains(prunedTargets, execution.searchChainRegistry());
    query.errors().addAll(regularTargetHandlers.errors());
    Set<Target> targetHandlers = new LinkedHashSet<>(regularTargetHandlers.data());
    targetHandlers.addAll(getAdditionalTargets(query, execution, targetSelector));
    traceTargets(query, targetHandlers);
    if (targetHandlers.isEmpty())
        return mergedResults;
    else if (targetHandlers.size() > 1)
        search(query, execution, targetHandlers, mergedResults);
    else if (shouldExecuteTargetLongerThanThread(query, targetHandlers.iterator().next()))
        // one target, but search in separate thread
        search(query, execution, targetHandlers, mergedResults);
    else
        // search in this thread
        search(query, execution, first(targetHandlers), mergedResults);
    return mergedResults;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SourcesTarget(com.yahoo.search.federation.sourceref.SourcesTarget) FederationTarget(com.yahoo.search.federation.selection.FederationTarget) SingleTarget(com.yahoo.search.federation.sourceref.SingleTarget) UnresolvedSearchChainException(com.yahoo.search.federation.sourceref.UnresolvedSearchChainException) ErrorMessage(com.yahoo.search.result.ErrorMessage) SearchChainInvocationSpec(com.yahoo.search.federation.sourceref.SearchChainInvocationSpec) Result(com.yahoo.search.Result) FutureResult(com.yahoo.search.searchchain.FutureResult)

Aggregations

Result (com.yahoo.search.Result)1 FederationTarget (com.yahoo.search.federation.selection.FederationTarget)1 SearchChainInvocationSpec (com.yahoo.search.federation.sourceref.SearchChainInvocationSpec)1 SingleTarget (com.yahoo.search.federation.sourceref.SingleTarget)1 SourcesTarget (com.yahoo.search.federation.sourceref.SourcesTarget)1 UnresolvedSearchChainException (com.yahoo.search.federation.sourceref.UnresolvedSearchChainException)1 ErrorMessage (com.yahoo.search.result.ErrorMessage)1 FutureResult (com.yahoo.search.searchchain.FutureResult)1 LinkedHashSet (java.util.LinkedHashSet)1