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());
}
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);
}
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);
}
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());
}
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"));
}
Aggregations