use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldRawContent.
@Test
public void testDocumentFieldRawContent() throws Exception {
byte[] contentBytes = new byte[] { 0, -128, 127 };
Document doc1 = new Document(docType, new DocumentId("userdoc:kittens:123:456"));
doc1.setFieldValue("foo", new Raw(ByteBuffer.wrap(contentBytes)));
GetDocumentReply[] replies = new GetDocumentReply[] { new GetDocumentReply(doc1) };
Chain<Searcher> searchChain = createSearcherChain(replies);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:123:456&field=foo"));
assertNull(result.hits().getErrorHit());
assertEquals("application/octet-stream", result.getTemplating().getTemplates().getMimeType());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
SearchRendererAdaptor.callRender(stream, result);
stream.flush();
byte[] resultBytes = stream.toByteArray();
assertEquals(contentBytes.length, resultBytes.length);
for (int i = 0; i < resultBytes.length; ++i) {
assertEquals(contentBytes[i], resultBytes[i]);
}
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class GetSearcherTestCase method testQueryOverridesConfig.
@Test
public void testQueryOverridesConfig() throws Exception {
String config = "raw:timeout 458\nroute \"route66\"";
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4&priority=LOW_2&route=highwaytohell&timeout=123"));
long lastTimeout = 123000;
assertEquals(2, factory.messages.size());
{
Message m = factory.messages.get(0);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("userdoc:kittens:1:2", d.toString());
assertEquals("[all]", gdm.getFieldSet());
assertEquals(DocumentProtocol.Priority.LOW_2, gdm.getPriority());
assertEquals(Route.parse("highwaytohell"), gdm.getRoute());
assertTrue(lastTimeout >= gdm.getTimeRemaining());
lastTimeout = gdm.getTimeRemaining();
}
{
Message m = factory.messages.get(1);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("userdoc:kittens:3:4", d.toString());
assertEquals("[all]", gdm.getFieldSet());
assertEquals(DocumentProtocol.Priority.LOW_2, gdm.getPriority());
assertEquals(Route.parse("highwaytohell"), gdm.getRoute());
assertTrue(lastTimeout >= gdm.getTimeRemaining());
}
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class GetSearcherTestCase method testLegacyHeadersOnly.
@Test
public void testLegacyHeadersOnly() throws Exception {
// Needs auto-reply
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:1:2&headersonly=true"));
assertEquals(1, factory.messages.size());
{
Message m = factory.messages.get(0);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("userdoc:kittens:1:2", d.toString());
assertEquals("[header]", gdm.getFieldSet());
}
assertEquals(1, result.hits().size());
assertHits(result.hits(), "userdoc:kittens:1:2");
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldWithMultipleIDs.
@Test
public void testDocumentFieldWithMultipleIDs() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4&field=name"));
assertNotNull(result.hits().getErrorHit());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"3\" message=\"Illegal query: " + "java.lang.IllegalArgumentException: Field only valid for single document id query\"/>\n" + "</errors>\n" + "</result>\n", result);
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class VisitorSearcherTestCase method testSimple.
@Test
public void testSimple() throws Exception {
Chain<Searcher> searchChain = new Chain<>(create());
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("visit?visit.selection=id.user=1234&hits=100"));
assertEquals(1, result.hits().size());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<document documenttype=\"kittens\" documentid=\"userdoc:foo:1234:bar\"/>\n" + "</result>\n", result);
}
Aggregations