Search in sources :

Example 1 with SearchChainInvocationSpec

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

the class FederationSearcher method commentedSourceProviderSearchChains.

private List<CommentedSearchChain> commentedSourceProviderSearchChains(SourcesTarget sourcesTarget, SearchChainRegistry registry) {
    List<CommentedSearchChain> commentedSearchChains = new ArrayList<>();
    String ifMatchingSourceRefPrefix = "If source refs contains '" + sourcesTarget.getId() + "' and provider is '";
    commentedSearchChains.add(new CommentedSearchChain(ifMatchingSourceRefPrefix + sourcesTarget.defaultProviderSource().provider + "'(or not given).", registry.getChain(sourcesTarget.defaultProviderSource().searchChainId)));
    for (SearchChainInvocationSpec providerSource : sourcesTarget.allProviderSources()) {
        if (!providerSource.equals(sourcesTarget.defaultProviderSource())) {
            commentedSearchChains.add(new CommentedSearchChain(ifMatchingSourceRefPrefix + providerSource.provider + "'.", registry.getChain(providerSource.searchChainId)));
        }
    }
    return commentedSearchChains;
}
Also used : ArrayList(java.util.ArrayList) SearchChainInvocationSpec(com.yahoo.search.federation.sourceref.SearchChainInvocationSpec)

Example 2 with SearchChainInvocationSpec

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

the class SearchChainResolverTestCase method lookup_provider.

// TODO: TVT: @Test()
public void lookup_provider() throws Exception {
    SearchChainInvocationSpec res = resolve(providerId.getName());
    assertThat(res.provider, is(providerId));
    assertNull(res.source);
    assertThat(res.searchChainId, is(providerId));
}
Also used : SearchChainInvocationSpec(com.yahoo.search.federation.sourceref.SearchChainInvocationSpec)

Example 3 with SearchChainInvocationSpec

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

the class SearchChainResolverTestCase method lookup_source_for_provider2.

@Test
public void lookup_source_for_provider2() throws Exception {
    SearchChainInvocationSpec res = resolve(sourceId.getName(), provider2Id.getName());
    assertThat(res.provider, is(provider2Id));
    assertThat(res.source, is(sourceId));
    assertThat(res.searchChainId, is(sourceChainInProvider2Id));
}
Also used : SearchChainInvocationSpec(com.yahoo.search.federation.sourceref.SearchChainInvocationSpec) Test(org.junit.Test)

Example 4 with SearchChainInvocationSpec

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

the class SearchChainResolverTestCase method lookup_search_chain.

@Test
public void lookup_search_chain() throws Exception {
    SearchChainInvocationSpec res = resolve(searchChainId.getName());
    assertThat(res.searchChainId, is(searchChainId));
}
Also used : SearchChainInvocationSpec(com.yahoo.search.federation.sourceref.SearchChainInvocationSpec) Test(org.junit.Test)

Example 5 with SearchChainInvocationSpec

use of com.yahoo.search.federation.sourceref.SearchChainInvocationSpec 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

SearchChainInvocationSpec (com.yahoo.search.federation.sourceref.SearchChainInvocationSpec)8 Test (org.junit.Test)4 Result (com.yahoo.search.Result)1 FederationTarget (com.yahoo.search.federation.selection.FederationTarget)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 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1