use of com.yahoo.search.federation.StrictContractsConfig in project vespa by vespa-engine.
the class FederationSearcherTestCase method twoTracingSources.
private Chain<Searcher> twoTracingSources(boolean strictContracts) {
addChained(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
query.trace(SOURCE1, 1);
return execution.search(query);
}
}, SOURCE1);
addChained(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
query.trace(SOURCE2, 1);
return execution.search(query);
}
}, SOURCE2);
Chain<Searcher> mainChain = new Chain<>("default", new FederationSearcher(new FederationConfig(builder), new StrictContractsConfig(new StrictContractsConfig.Builder().searchchains(strictContracts)), new ComponentRegistry<>()));
return mainChain;
}
use of com.yahoo.search.federation.StrictContractsConfig in project vespa by vespa-engine.
the class FederationSearcherTestCase method createStrictFederationSearcher.
private Searcher createStrictFederationSearcher() {
StrictContractsConfig.Builder builder = new StrictContractsConfig.Builder();
builder.searchchains(true);
return buildFederation(new StrictContractsConfig(builder));
}
use of com.yahoo.search.federation.StrictContractsConfig in project vespa by vespa-engine.
the class FederationSearcherTest method custom_federation_target.
@Test
public void custom_federation_target() {
ComponentId targetSelectorId = ComponentId.fromString("TargetSelector");
ComponentRegistry<TargetSelector> targetSelectors = new ComponentRegistry<>();
targetSelectors.register(targetSelectorId, new TestTargetSelector());
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());
HitGroup myChainGroup = (HitGroup) result.hits().get(0);
assertThat(myChainGroup.getId(), is(new URI("source:myChain")));
assertThat(myChainGroup.get(0).getId(), is(new URI("myHit")));
}
use of com.yahoo.search.federation.StrictContractsConfig 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"));
}
Aggregations