use of com.yahoo.search.searchchain.SearchChain in project vespa by vespa-engine.
the class OutputSearchChain method getSearchChain.
private SearchChain getSearchChain(SearchChainRegistry registry, String searchChainName) {
SearchChain searchChain = registry.getComponent(searchChainName);
ensureNotNull("There is no search chain named '" + searchChainName + "'", searchChain);
return searchChain;
}
use of com.yahoo.search.searchchain.SearchChain in project vespa by vespa-engine.
the class SearchChainConfigurerTestCase method testConfigurableSearcher.
@Test
public void testConfigurableSearcher() {
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir);
SearchChain configurable = getSearchChainRegistryFrom(configurer).getComponent("configurable");
assertNotNull(configurable);
Searcher s = configurable.searchers().get(0);
assertThat(s, instanceOf(ConfigurableSearcher.class));
ConfigurableSearcher searcher = (ConfigurableSearcher) s;
assertThat("Value from int.cfg file", searcher.intConfig.intVal(), is(7));
assertThat("Value from string.cfg file", searcher.stringConfig.stringVal(), is("com.yahoo.search.searchchain.config.test"));
configurer.shutdown();
}
use of com.yahoo.search.searchchain.SearchChain in project vespa by vespa-engine.
the class SearchChainConfigurerTestCase method testConfiguration.
@Test
public synchronized void testConfiguration() throws Exception {
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir);
SearchChain simple = getSearchChainRegistryFrom(configurer).getComponent("simple");
assertNotNull(simple);
assertThat(getSearcherNumbers(simple), is(Arrays.asList(1, 2, 3)));
SearchChain child1 = getSearchChainRegistryFrom(configurer).getComponent("child:1");
assertThat(getSearcherNumbers(child1), is(Arrays.asList(1, 2, 4, 5, 7, 8)));
SearchChain child2 = getSearchChainRegistryFrom(configurer).getComponent("child");
assertThat(getSearcherNumbers(child2), is(Arrays.asList(3, 6, 7, 9)));
// Verify successful loading of an explicitly declared searcher that takes no user-defined configs.
// assertNotNull(SearchChainRegistry.get().getSearcherRegistry().getComponent
// ("com.yahoo.search.searchchain.config.test.SearchChainConfigurerTestCase$DeclaredTestSearcher"));
configurer.shutdown();
}
use of com.yahoo.search.searchchain.SearchChain in project vespa by vespa-engine.
the class SearchChainTestCase method testEmptySearchChain.
@Test
public void testEmptySearchChain() {
SearchChain empty = new SearchChain(new ComponentId("empty"));
assertEquals("empty", empty.getId().getName());
}
use of com.yahoo.search.searchchain.SearchChain in project vespa by vespa-engine.
the class OutputSearchChain method invoke.
public void invoke(Request request) {
try {
SearchHandler searchHandler = SearcherUtils.getSearchHandler();
SearchChainRegistry searchChainRegistry = searchHandler.getSearchChainRegistry();
SearchChain searchChain = getSearchChain(searchChainRegistry, getSearchChainName(request));
SearchChainTextRepresentation textRepresentation = new SearchChainTextRepresentation(searchChain, searchChainRegistry);
request.returnValues().add(new StringValue(textRepresentation.toString()));
} catch (Exception e) {
request.setError(1000, Exceptions.toMessageString(e));
}
}
Aggregations