Search in sources :

Example 51 with Searcher

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();
}
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 52 with Searcher

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);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) JSONString(com.yahoo.prelude.hitfield.JSONString) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 53 with Searcher

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);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher)

Example 54 with Searcher

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());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) AsyncExecution(com.yahoo.search.searchchain.AsyncExecution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FutureResult(com.yahoo.search.searchchain.FutureResult) Result(com.yahoo.search.Result)

Example 55 with Searcher

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"));
}
Also used : Chain(com.yahoo.component.chain.Chain) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) ArrayList(java.util.ArrayList) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) ComponentId(com.yahoo.component.ComponentId)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8