use of com.yahoo.search.Searcher 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.Searcher in project vespa by vespa-engine.
the class JsonRendererTestCase method testTracing.
@Test
public final void testTracing() throws IOException, InterruptedException, ExecutionException {
// which clearly shows a trace child is created once too often...
String expected = "{\n" + " \"root\": {\n" + " \"fields\": {\n" + " \"totalCount\": 0\n" + " },\n" + " \"id\": \"toplevel\",\n" + " \"relevance\": 1.0\n" + " },\n" + " \"trace\": {\n" + " \"children\": [\n" + " {\n" + " \"message\": \"No query profile is used\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"message\": \"something\"\n" + " },\n" + " {\n" + " \"message\": \"something else\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"message\": \"yellow\"\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"message\": \"marker\"\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + " }\n" + "}\n";
Query q = new Query("/?query=a&tracelevel=1");
Execution execution = new Execution(Execution.Context.createContextStub());
Result r = new Result(q);
execution.search(q);
q.trace("something", 1);
q.trace("something else", 1);
Execution e2 = new Execution(new Chain<Searcher>(), execution.context());
Query subQuery = new Query("/?query=b&tracelevel=1");
e2.search(subQuery);
subQuery.trace("yellow", 1);
q.trace("marker", 1);
String summary = render(execution, r);
assertEqualJson(expected, summary);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class JsonRendererTestCase method subExecution.
private void subExecution(Execution execution, String color, int traceLevel) {
Execution e2 = new Execution(new Chain<Searcher>(), execution.context());
Query subQuery = new Query("/?query=b&tracelevel=" + traceLevel);
e2.search(subQuery);
subQuery.trace(color, 1);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class AsyncExecutionOfOneChainTestCase method testParallelExecutionOfOneChain.
/**
* Tests having a result with some slow source data which should pass directly to rendering
*/
public void testParallelExecutionOfOneChain() {
// Setup
Chain<Searcher> mainChain = new Chain<>(new ParallelExecutor(), new ResultProcessor(), new RegularProvider());
// Execute
Result result = new Execution(mainChain, Execution.Context.createContextStub()).search(new Query());
// Verify
assertEquals("Received 2 hits from 3 threads", 3 * 2, result.hits().size());
assertEquals(1.0, result.hits().get("thread-0:hit-0").getRelevance().getScore());
assertEquals(1.0, result.hits().get("thread-1:hit-0").getRelevance().getScore());
assertEquals(1.0, result.hits().get("thread-2:hit-0").getRelevance().getScore());
assertEquals(0.5, result.hits().get("thread-0:hit-1").getRelevance().getScore());
assertEquals(0.5, result.hits().get("thread-1:hit-1").getRelevance().getScore());
assertEquals(0.5, result.hits().get("thread-2:hit-1").getRelevance().getScore());
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class ExecutionTestCase method testNestedExecution.
public void testNestedExecution() {
// Make a chain
List<Searcher> searchers1 = new ArrayList<>();
searchers1.add(new FillableTestSearcher("searcher1"));
searchers1.add(new WorkflowSearcher());
searchers1.add(new TestSearcher("searcher2"));
searchers1.add(new FillingSearcher());
searchers1.add(new FillableTestSearcherAtTheEnd("searcher3"));
Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
// Execute it
Query query = new Query("test");
Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
// Verify results
assertEquals(7, result1.getConcreteHitCount());
assertNotNull(result1.hits().get("searcher1-1"));
assertNotNull(result1.hits().get("searcher2-1"));
assertNotNull(result1.hits().get("searcher3-1"));
assertNotNull(result1.hits().get("searcher3-1-filled"));
assertNotNull(result1.hits().get("searcher2-2"));
assertNotNull(result1.hits().get("searcher3-2"));
assertNotNull(result1.hits().get("searcher3-2-filled"));
}
Aggregations