Search in sources :

Example 81 with Execution

use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.

the class RewriterFeaturesTestCase method testConvertStringToQTree.

@Test
public final void testConvertStringToQTree() {
    Execution placeholder = new Execution(Context.createContextStub());
    SpecialTokenRegistry tokenRegistry = new SpecialTokenRegistry(new SpecialtokensConfig(new SpecialtokensConfig.Builder().tokenlist(new Tokenlist.Builder().name("default").tokens(new Tokens.Builder().token(ASCII_ELLIPSIS)))));
    placeholder.context().setTokenRegistry(tokenRegistry);
    Query query = new Query();
    query.getModel().setExecution(placeholder);
    Item parsed = RewriterFeatures.convertStringToQTree(query, "a b c " + ASCII_ELLIPSIS);
    assertSame(AndItem.class, parsed.getClass());
    assertEquals(4, ((CompositeItem) parsed).getItemCount());
    assertEquals(ASCII_ELLIPSIS, ((CompositeItem) parsed).getItem(3).toString());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) Item(com.yahoo.prelude.query.Item) AndItem(com.yahoo.prelude.query.AndItem) CompositeItem(com.yahoo.prelude.query.CompositeItem) Execution(com.yahoo.search.searchchain.Execution) SpecialTokenRegistry(com.yahoo.prelude.query.parser.SpecialTokenRegistry) Query(com.yahoo.search.Query) SpecialtokensConfig(com.yahoo.vespa.configdefinition.SpecialtokensConfig) Tokenlist(com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist) Tokens(com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist.Tokens) Test(org.junit.Test)

Example 82 with Execution

use of com.yahoo.search.searchchain.Execution 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 83 with Execution

use of com.yahoo.search.searchchain.Execution 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 84 with Execution

use of com.yahoo.search.searchchain.Execution 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 85 with Execution

use of com.yahoo.search.searchchain.Execution 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

Execution (com.yahoo.search.searchchain.Execution)232 Query (com.yahoo.search.Query)184 Result (com.yahoo.search.Result)127 Test (org.junit.Test)123 Searcher (com.yahoo.search.Searcher)88 Chain (com.yahoo.component.chain.Chain)59 IndexFacts (com.yahoo.prelude.IndexFacts)34 Hit (com.yahoo.search.result.Hit)25 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 AndItem (com.yahoo.prelude.query.AndItem)18 WordItem (com.yahoo.prelude.query.WordItem)17 ComponentId (com.yahoo.component.ComponentId)13 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FastHit (com.yahoo.prelude.fastsearch.FastHit)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)13 ArrayList (java.util.ArrayList)12 CompositeItem (com.yahoo.prelude.query.CompositeItem)11