Search in sources :

Example 71 with Searcher

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);
    }
}
Also used : PingableSearcher(com.yahoo.search.cluster.PingableSearcher) Searcher(com.yahoo.search.Searcher) Pong(com.yahoo.prelude.Pong)

Example 72 with Searcher

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);
    }
}
Also used : PingableSearcher(com.yahoo.search.cluster.PingableSearcher) Searcher(com.yahoo.search.Searcher)

Example 73 with Searcher

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());
    }
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Searcher(com.yahoo.search.Searcher) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Example 74 with Searcher

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]);
    }
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Searcher(com.yahoo.search.Searcher) Raw(com.yahoo.document.datatypes.Raw) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 75 with Searcher

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);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Searcher(com.yahoo.search.Searcher) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8