use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class FastSearcherTestCase method testThatPropertiesAreReencoded.
@Test
public void testThatPropertiesAreReencoded() throws Exception {
FastSearcher fastSearcher = createFastSearcher();
// Default cache =100MB
assertEquals(100, fastSearcher.getCacheControl().capacity());
Query query = new Query("?query=ignored");
query.getRanking().setQueryCache(true);
Result result = doSearch(fastSearcher, query, 0, 10);
Execution execution = new Execution(chainedAsSearchChain(fastSearcher), Execution.Context.createContextStub());
assertEquals(2, result.getHitCount());
execution.fill(result);
BasicPacket receivedPacket = mockBackend.getChannel().getLastReceived();
ByteBuffer buf = ByteBuffer.allocate(1000);
receivedPacket.encode(buf);
buf.flip();
byte[] actual = new byte[buf.remaining()];
buf.get(actual);
SessionId sessionId = query.getSessionId(false);
byte IGNORE = 69;
ByteBuffer answer = ByteBuffer.allocate(1024);
answer.put(new byte[] { 0, 0, 0, (byte) (145 + sessionId.asUtf8String().getByteLength()), 0, 0, 0, -37, 0, 0, 48, 17, 0, 0, 0, 0, // query timeout
IGNORE, IGNORE, IGNORE, IGNORE, // "default" - rank profile
7, 'd', 'e', 'f', 'a', 'u', 'l', 't', 0, 0, 0, 0x03, // 3 property entries (rank, match, caches)
0, 0, 0, 3, // rank: sessionId => qrserver.0.XXXXXXXXXXXXX.0
0, 0, 0, 4, 'r', 'a', 'n', 'k', 0, 0, 0, 1, 0, 0, 0, 9, 's', 'e', 's', 's', 'i', 'o', 'n', 'I', 'd' });
answer.putInt(sessionId.asUtf8String().getBytes().length);
answer.put(sessionId.asUtf8String().getBytes());
answer.put(new byte[] { // match: documentdb.searchdoctype => test
0, 0, 0, 5, 'm', 'a', 't', 'c', 'h', 0, 0, 0, 1, 0, 0, 0, 24, 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 'd', 'b', '.', 's', 'e', 'a', 'r', 'c', 'h', 'd', 'o', 'c', 't', 'y', 'p', 'e', 0, 0, 0, 4, 't', 'e', 's', 't', // sessionId => qrserver.0.XXXXXXXXXXXXX.0
0, 0, 0, 6, 'c', 'a', 'c', 'h', 'e', 's', 0, 0, 0, 1, 0, 0, 0, 5, 'q', 'u', 'e', 'r', 'y', 0, 0, 0, 4, 't', 'r', 'u', 'e', // flags
0, 0, 0, 2 });
byte[] expected = new byte[answer.position()];
answer.flip();
answer.get(expected);
assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; ++i) {
if (expected[i] == IGNORE) {
actual[i] = IGNORE;
}
}
assertArrayEquals(expected, actual);
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class FastSearcherTestCase method testSinglePassGroupingIsNotForcedWithSingleNodeGroups.
@Test
public void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
MockDispatcher dispatcher = new MockDispatcher(ImmutableList.of(new SearchCluster.Node("host0", 123, 0), new SearchCluster.Node("host1", 123, 0)));
FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), dispatcher, new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
Query q = new Query("?query=foo");
GroupingRequest request1 = GroupingRequest.newInstance(q);
request1.setRootOperation(new AllOperation());
GroupingRequest request2 = GroupingRequest.newInstance(q);
AllOperation all = new AllOperation();
all.addChild(new EachOperation());
all.addChild(new EachOperation());
request2.setRootOperation(all);
assertForceSinglePassIs(false, q);
fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
assertForceSinglePassIs(false, q);
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class PageTemplateSearcherTestCase method testSearcher.
public void testSearcher() {
PageTemplateSearcher s = new PageTemplateSearcher(createPageTemplateRegistry(), new FirstChoiceResolver());
Chain<Searcher> chain = new Chain<>(s, new MockFederator());
{
// No template specified, should use default
Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.resolver=native.deterministic"));
assertSources("source1 source2", result);
}
{
Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.id=oneSource&page.resolver=native.deterministic"));
assertSources("source1", result);
}
{
Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.id=twoSources&model.sources=source1&page.resolver=native.deterministic"));
assertSources("source1", result);
}
{
Query query = new Query("?query=foo&page.resolver=native.deterministic");
addIntentModelSpecifyingSource3(query);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source1 source2", result);
}
{
Query query = new Query("?query=foo&page.id=twoSourcesAndAny&page.resolver=native.deterministic");
addIntentModelSpecifyingSource3(query);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source1 source2 source3", result);
}
{
Query query = new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
addIntentModelSpecifyingSource3(query);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source3", result);
}
{
Query query = new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertTrue(query.getModel().getSources().isEmpty());
assertNotNull(result.hits().get("source1"));
assertNotNull(result.hits().get("source2"));
assertNotNull(result.hits().get("source3"));
}
{
Query query = new Query("?query=foo&page.id=choiceOfSources&page.resolver=native.deterministic");
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source1 source2", "source2", result);
}
{
Query query = new Query("?query=foo&page.id=choiceOfSources&page.resolver=test.firstChoice");
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source1 source2", "source1", result);
}
{
// Specifying two templates, should pick the last
Query query = new Query("?query=foo&page.id=threeSources+oneSource&page.resolver=native.deterministic");
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source1 source2 source3", "source1", result);
}
{
// Specifying two templates as a list, should override the page.id setting
Query query = new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
query.properties().set("page.idList", Arrays.asList("oneSource", "threeSources"));
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSources("source1 source2 source3", "source1 source2 source3", result);
}
{
try {
Query query = new Query("?query=foo&page.id=oneSource+choiceOfSources&page.resolver=noneSuch");
new Execution(chain, Execution.Context.createContextStub()).search(query);
fail("Expected exception");
} catch (IllegalArgumentException e) {
assertEquals("No page template resolver 'noneSuch'", e.getMessage());
}
}
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class QueryMarshallerTestCase method testQueryString.
private void testQueryString(QueryMarshaller marshaller, String uq, String mq, String lang, Linguistics linguistics) {
Query query = new Query("/?query=" + QueryTestCase.httpEncode(uq) + ((lang != null) ? "&language=" + lang : ""));
query.getModel().setExecution(new Execution(new Execution.Context(null, new IndexFacts(), null, null, linguistics)));
assertEquals(mq, marshaller.marshal(query.getModel().getQueryTree().getRoot()));
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class VespaSearcherTestCase method testVespaSearcher.
public void testVespaSearcher() {
VespaSearcher v = new VespaSearcherValidatingSubclass();
new Execution(v, Execution.Context.createContextStub()).search(new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&filter=myfilter")));
}
Aggregations