Search in sources :

Example 6 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class GetSearcherTestCase method testQueryOverridesDefaults.

@Test
public void testQueryOverridesDefaults() 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&priority=LOW_2&route=highwaytohell&timeout=58"));
    assertEquals(2, factory.messages.size());
    long lastTimeout = 58000;
    {
        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());
    }
}
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) 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 7 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class GetSearcherTestCase method testGetSingleDocumentQuery.

@Test
public void testGetSingleDocumentQuery() 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"));
    System.out.println("HTTP request is " + result.getQuery().getHttpRequest());
    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("[all]", gdm.getFieldSet());
    }
    assertEquals(1, result.hits().size());
    assertHits(result.hits(), "userdoc:kittens:1:2");
    // By default, document hit should not have its hit fields set
    DocumentHit hit = (DocumentHit) result.hits().get(0);
    assertEquals(0, hit.fieldKeys().size());
}
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) 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 8 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class GetSearcherTestCase method testGetMultipleDocumentsQuery.

@Test
public void testGetMultipleDocumentsQuery() 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);
    Query query = newQuery("?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4");
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
    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());
    }
    {
        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(2, result.hits().size());
    assertNull(result.hits().getErrorHit());
    assertHits(result.hits(), "userdoc:kittens:1:2", "userdoc:kittens:3:4");
    assertEquals(2, query.getHits());
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Query(com.yahoo.search.Query) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Searcher(com.yahoo.search.Searcher) 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 9 with Message

use of com.yahoo.messagebus.Message 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());
    }
}
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) 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 10 with Message

use of com.yahoo.messagebus.Message 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");
}
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) 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)

Aggregations

Message (com.yahoo.messagebus.Message)39 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)17 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)15 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)15 Reply (com.yahoo.messagebus.Reply)14 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)13 Test (org.junit.Test)13 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)9 Chain (com.yahoo.component.chain.Chain)7 FeedContext (com.yahoo.feedapi.FeedContext)7 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)7 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)7 Searcher (com.yahoo.search.Searcher)7 Execution (com.yahoo.search.searchchain.Execution)7 ClusterList (com.yahoo.vespaclient.ClusterList)7 Result (com.yahoo.search.Result)6 Utf8String (com.yahoo.text.Utf8String)6 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)5 Tuple2 (com.yahoo.collections.Tuple2)4 EmptyReply (com.yahoo.messagebus.EmptyReply)4