Search in sources :

Example 6 with FederationSearcher

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

the class FederationSearcherTest method target_selectors_can_have_multiple_targets.

@Test
public void target_selectors_can_have_multiple_targets() {
    ComponentId targetSelectorId = ComponentId.fromString("TestMultipleTargetSelector");
    ComponentRegistry<TargetSelector> targetSelectors = new ComponentRegistry<>();
    targetSelectors.register(targetSelectorId, new TestMultipleTargetSelector());
    FederationSearcher searcher = new FederationSearcher(new FederationConfig(new FederationConfig.Builder().targetSelector(targetSelectorId.toString())), new StrictContractsConfig(new StrictContractsConfig.Builder()), targetSelectors);
    Result result = new Execution(searcher, Context.createContextStub()).search(new Query());
    Iterator<Hit> hitsIterator = result.hits().deepIterator();
    Hit hit1 = hitsIterator.next();
    Hit hit2 = hitsIterator.next();
    assertThat(hit1.getSource(), is("chain1"));
    assertThat(hit2.getSource(), is("chain2"));
    assertThat((String) hit1.getField("data"), is("modifyTargetQuery:custom-data:1"));
    assertThat((String) hit2.getField("data"), is("modifyTargetQuery:custom-data:2"));
}
Also used : FederationSearcher(com.yahoo.search.federation.FederationSearcher) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) StrictContractsConfig(com.yahoo.search.federation.StrictContractsConfig) ErrorHit(com.yahoo.search.result.ErrorHit) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) TargetSelector(com.yahoo.search.federation.selection.TargetSelector) ComponentId(com.yahoo.component.ComponentId) FederationConfig(com.yahoo.search.federation.FederationConfig) Test(org.junit.Test)

Aggregations

FederationSearcher (com.yahoo.search.federation.FederationSearcher)6 ComponentId (com.yahoo.component.ComponentId)5 Query (com.yahoo.search.Query)5 Result (com.yahoo.search.Result)5 Execution (com.yahoo.search.searchchain.Execution)5 Test (org.junit.Test)4 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)3 FederationConfig (com.yahoo.search.federation.FederationConfig)3 StrictContractsConfig (com.yahoo.search.federation.StrictContractsConfig)3 SearchChainResolver (com.yahoo.search.federation.sourceref.SearchChainResolver)3 Chain (com.yahoo.component.chain.Chain)2 Searcher (com.yahoo.search.Searcher)2 TargetSelector (com.yahoo.search.federation.selection.TargetSelector)2 Hit (com.yahoo.search.result.Hit)2 HitGroup (com.yahoo.search.result.HitGroup)2 SearchChainRegistry (com.yahoo.search.searchchain.SearchChainRegistry)2 FederationOptions (com.yahoo.search.searchchain.model.federation.FederationOptions)2 ImmutableList (com.google.common.collect.ImmutableList)1 URI (com.yahoo.net.URI)1 IndexFacts (com.yahoo.prelude.IndexFacts)1