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;
}
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));
}
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));
}
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));
}
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;
}
Aggregations