use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class ClusterSearcherTestCase method testThatWeCanSpecifyNumHitsAndHitOffset.
@Test
public void testThatWeCanSpecifyNumHitsAndHitOffset() {
Execution ex = createExecution();
// all types
assertResult(9, Arrays.asList(11.0, 10.0), getResult(0, 2, ex));
assertResult(9, Arrays.asList(10.0, 9.0), getResult(1, 2, ex));
assertResult(9, Arrays.asList(9.0, 8.0), getResult(2, 2, ex));
assertResult(9, Arrays.asList(8.0, 7.0), getResult(3, 2, ex));
assertResult(9, Arrays.asList(7.0, 6.0), getResult(4, 2, ex));
assertResult(9, Arrays.asList(6.0, 5.0), getResult(5, 2, ex));
assertResult(9, Arrays.asList(5.0, 4.0), getResult(6, 2, ex));
assertResult(9, Arrays.asList(4.0, 3.0), getResult(7, 2, ex));
assertResult(9, Arrays.asList(3.0), getResult(8, 2, ex));
assertResult(9, new ArrayList<Double>(), getResult(9, 2, ex));
assertResult(9, Arrays.asList(11.0, 10.0, 9.0, 8.0, 7.0), getResult(0, 5, ex));
assertResult(9, Arrays.asList(6.0, 5.0, 4.0, 3.0), getResult(5, 5, ex));
// restrict=type1
assertResult(3, Arrays.asList(9.0, 6.0), getResult(0, 2, "&restrict=type1", ex));
assertResult(3, Arrays.asList(6.0, 3.0), getResult(1, 2, "&restrict=type1", ex));
assertResult(3, Arrays.asList(3.0), getResult(2, 2, "&restrict=type1", ex));
assertResult(3, new ArrayList<>(), getResult(3, 2, "&restrict=type1", ex));
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class ClusterSearcherTestCase method testNoBackends.
@Test
public void testNoBackends() {
ClusterSearcher cluster = new ClusterSearcher(new LinkedHashSet<>(Arrays.asList("dummy")));
try {
cluster.getMonitor().getConfiguration().setRequestTimeout(100);
Execution execution = new Execution(cluster, Execution.Context.createContextStub());
Query query = new Query("query=hello");
query.setHits(10);
com.yahoo.search.Result result = execution.search(query);
assertTrue(result.hits().getError() != null);
assertEquals("No backends in service. Try later", result.hits().getError().getMessage());
} finally {
cluster.deconstruct();
}
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class SearchHandler method searchAndFill.
/**
* Used from container SDK, for internal use only
*/
public Result searchAndFill(Query query, Chain<? extends Searcher> searchChain, SearchChainRegistry registry) {
Result errorResult = validateQuery(query);
if (errorResult != null)
return errorResult;
Renderer<Result> renderer = rendererRegistry.getRenderer(query.getPresentation().getRenderer());
// here too in which case it will still be "unset" after we set it :-)
if (query.getPresentation().getSummary() == null && renderer instanceof com.yahoo.search.rendering.Renderer)
query.getPresentation().setSummary(((com.yahoo.search.rendering.Renderer) renderer).getDefaultSummaryClass());
Execution execution = new Execution(searchChain, new Execution.Context(registry, indexFacts, specialTokens, rendererRegistry, linguistics));
query.getModel().setExecution(execution);
execution.trace().setForceTimestamps(query.properties().getBoolean(FORCE_TIMESTAMPS, false));
if (query.properties().getBoolean(DETAILED_TIMING_LOGGING, false)) {
// check and set (instead of set directly) to avoid overwriting stuff from prepareForBreakdownAnalysis()
execution.context().setDetailedDiagnostics(true);
}
Result result = execution.search(query);
if (result.getTemplating() == null)
result.getTemplating().setRenderer(renderer);
ensureQuerySet(result, query);
execution.fill(result, result.getQuery().getPresentation().getSummary());
traceExecutionTimes(query, result);
traceVespaVersion(query);
traceRequestAttributes(query);
return result;
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class AsyncExecutionTestCase method testSync.
public void testSync() {
Query query = new Query("?query=test");
Searcher searcher = new ResultProducingSearcher();
Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
assertEquals(1, result.hits().size());
assertEquals("hello", result.hits().get(0).getField("test"));
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class AsyncExecutionTestCase method testSyncThroughSync.
public void testSyncThroughSync() {
Query query = new Query("?query=test");
Searcher searcher = new ResultProducingSearcher();
Result result = new Execution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
assertEquals(1, result.hits().size());
assertEquals("hello", result.hits().get(0).getField("test"));
}
Aggregations