use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class Execution method ping.
/**
* Calls ping on the next search in this chain. If there is no next, a Pong is created and returned.
*/
public Pong ping(Ping ping) {
// return this reference, not directly. It's needed for adding time data
Pong annotationReference = null;
timer.samplePing(nextIndex(), context.getDetailedDiagnostics());
// TODO: Allow but skip processors which are not searchers
Searcher next = (Searcher) next();
if (next == null) {
annotationReference = new Pong();
return annotationReference;
}
try {
nextProcessor();
annotationReference = invokePing(ping, next);
return annotationReference;
} finally {
previousProcessor();
timer.samplePingReturn(nextIndex(), context.getDetailedDiagnostics(), annotationReference);
}
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class Execution method fill.
/**
* Calls fill on the next searcher in this chain. If there is no next, nothing is done.
*/
public void fill(Result result, String summaryClass) {
timer.sampleFill(nextIndex(), context.getDetailedDiagnostics());
// TODO: Allow but skip processors which are not searchers
Searcher current = (Searcher) next();
if (current == null)
return;
try {
nextProcessor();
onInvokingFill(current, result, summaryClass);
current.ensureFilled(result, summaryClass, this);
} finally {
previousProcessor();
onReturningFill(current, result, summaryClass);
timer.sampleFillReturn(nextIndex(), context.getDetailedDiagnostics(), result);
}
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testConfig.
@Test
public void testConfig() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder().timeout(58).route("route66").retryenabled(false)), defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=doc:batman:dahnahnahnah"));
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("doc:batman:dahnahnahnah", d.toString());
assertEquals("[all]", gdm.getFieldSet());
assertEquals(Route.parse("route66"), gdm.getRoute());
assertFalse(gdm.getRetryEnabled());
assertTrue(58000 >= gdm.getTimeRemaining());
}
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldRawWithContentOverride.
@Test
public void testDocumentFieldRawWithContentOverride() 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&contenttype=text/fancy"));
assertNull(result.hits().getErrorHit());
assertEquals("text/fancy", 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.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldNotReachableWithHeadersOnly.
@Test
public void testDocumentFieldNotReachableWithHeadersOnly() throws Exception {
Document doc1 = new Document(docType, new DocumentId("userdoc:kittens:5:1"));
doc1.setFieldValue("name", "asdf");
// don't set body fields
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:5:1&field=description&headersonly=true"));
assertNotNull(result.hits().getErrorHit());
assertEquals(1, result.hits().size());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"4\" message=\"Invalid query parameter: " + "Field 'description' is located in document body, but headersonly " + "prevents it from being retrieved in userdoc:kittens:5:1\"/>\n" + "</errors>\n" + "</result>\n", result);
}
Aggregations