Search in sources :

Example 1 with ClusterList

use of com.yahoo.vespaclient.ClusterList 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 2 with ClusterList

use of com.yahoo.vespaclient.ClusterList 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 3 with ClusterList

use of com.yahoo.vespaclient.ClusterList in project vespa by vespa-engine.

the class GetSearcherTestCase method testDocumentFieldWithDocumentNotFound.

@Test
public void testDocumentFieldWithDocumentNotFound() throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType, null, true);
    factory.setNullReply(true);
    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&field=name"));
    assertNotNull(result.hits().getErrorHit());
    assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"16\" message=\"Resource not found.: " + "Document not found, could not return field 'name'\"/>\n" + "</errors>\n" + "</result>\n", result);
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) Searcher(com.yahoo.search.Searcher) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 4 with ClusterList

use of com.yahoo.vespaclient.ClusterList 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 5 with ClusterList

use of com.yahoo.vespaclient.ClusterList in project vespa by vespa-engine.

the class GetSearcherTestCase method createSearcherChain.

private Chain<Searcher> createSearcherChain(GetDocumentReply[] replies) throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType, null, false, replies);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    return new Chain<>(searcher);
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) FeedContext(com.yahoo.feedapi.FeedContext) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric)

Aggregations

ClusterList (com.yahoo.vespaclient.ClusterList)34 Test (org.junit.Test)29 FeedContext (com.yahoo.feedapi.FeedContext)25 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)24 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)24 Chain (com.yahoo.component.chain.Chain)21 Searcher (com.yahoo.search.Searcher)20 Execution (com.yahoo.search.searchchain.Execution)20 Result (com.yahoo.search.Result)19 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)8 Message (com.yahoo.messagebus.Message)7 ClusterDef (com.yahoo.vespaclient.ClusterDef)7 FeederConfig (com.yahoo.vespaclient.config.FeederConfig)5 ArrayList (java.util.ArrayList)5 Query (com.yahoo.search.Query)4 ClusterListConfig (com.yahoo.cloud.config.ClusterListConfig)2 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)2 Hit (com.yahoo.search.result.Hit)2 HitGroup (com.yahoo.search.result.HitGroup)2 LoadTypeConfig (com.yahoo.vespa.config.content.LoadTypeConfig)2