Search in sources :

Example 1 with SearchChain

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;
}
Also used : SearchChain(com.yahoo.search.searchchain.SearchChain)

Example 2 with 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();
}
Also used : HandlersConfigurerTestWrapper(com.yahoo.container.core.config.testutil.HandlersConfigurerTestWrapper) Searcher(com.yahoo.search.Searcher) SearchChain(com.yahoo.search.searchchain.SearchChain) Test(org.junit.Test)

Example 3 with SearchChain

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();
}
Also used : HandlersConfigurerTestWrapper(com.yahoo.container.core.config.testutil.HandlersConfigurerTestWrapper) SearchChain(com.yahoo.search.searchchain.SearchChain) Test(org.junit.Test)

Example 4 with SearchChain

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());
}
Also used : SearchChain(com.yahoo.search.searchchain.SearchChain) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 5 with SearchChain

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));
    }
}
Also used : SearchHandler(com.yahoo.search.handler.SearchHandler) SearchChainRegistry(com.yahoo.search.searchchain.SearchChainRegistry) SearchChain(com.yahoo.search.searchchain.SearchChain) StringValue(com.yahoo.jrt.StringValue)

Aggregations

SearchChain (com.yahoo.search.searchchain.SearchChain)6 Test (org.junit.Test)3 ComponentId (com.yahoo.component.ComponentId)2 HandlersConfigurerTestWrapper (com.yahoo.container.core.config.testutil.HandlersConfigurerTestWrapper)2 StringValue (com.yahoo.jrt.StringValue)1 Searcher (com.yahoo.search.Searcher)1 FederationConfig (com.yahoo.search.federation.FederationConfig)1 SearchHandler (com.yahoo.search.handler.SearchHandler)1 SearchChainRegistry (com.yahoo.search.searchchain.SearchChainRegistry)1