Search in sources :

Example 21 with ClusterList

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

the class GetSearcherTestCase method testResultWithSingleError.

@Test
public void testResultWithSingleError() throws Exception {
    com.yahoo.messagebus.Error err = new com.yahoo.messagebus.Error(32, "Alas, it went poorly");
    DocumentSessionFactory factory = new DocumentSessionFactory(docType, err, 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[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4"));
    assertNotNull(result.hits().getErrorHit());
    assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"messagebus\" code=\"32\" message=\"Alas, it went poorly\"/>\n" + "</errors>\n" + "</result>\n", result);
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Example 22 with ClusterList

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

the class GetSearcherTestCase method testGetMultipleDocumentsQueryAndGZippedPOST.

@Test
public void testGetMultipleDocumentsQueryAndGZippedPOST() 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);
    String data = "userdoc:kittens:5:6\nuserdoc:kittens:7:8\nuserdoc:kittens:9:10";
    // Create with automatic GZIP encoding
    MockHttpRequest request = new MockHttpRequest(data.getBytes("utf-8"), "/get/?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4", true);
    Query query = new Query(request.toRequest());
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
    assertEquals(5, factory.messages.size());
    assertEquals(5, result.hits().size());
    assertNull(result.hits().getErrorHit());
    assertHits(result.hits(), "userdoc:kittens:1:2", "userdoc:kittens:3:4", "userdoc:kittens:5:6", "userdoc:kittens:7:8", "userdoc:kittens:9:10");
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Example 23 with ClusterList

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

the class GetSearcherTestCase method testQueryPassThrough.

/* Test that a query without any ids is passed through to the next chain */
@Test
public void testQueryPassThrough() throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    HitGroup hits = new HitGroup("mock");
    hits.add(new Hit("blernsball"));
    Chain<Searcher> searchChain = new Chain<>(searcher, new MockBackend(hits));
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?flarn=blern"));
    assertEquals(0, factory.messages.size());
    assertEquals(1, result.hits().size());
    assertNotNull(result.hits().get("blernsball"));
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 24 with ClusterList

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

the class GetSearcherTestCase method testResultWithNullDocument.

@Test
public void testResultWithNullDocument() 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[0]=userdoc:kittens:55:bad_document_id"));
    // Document not found does not produce any hit at all, error or otherwise
    assertNull(result.hits().getErrorHit());
    assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\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 25 with ClusterList

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

the class GetSearcherTestCase method testBadPriorityValue.

@Test
public void testBadPriorityValue() 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=userdoc:kittens:1:2&priority=onkel_jubalon"));
    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: No enum const" + (Util.isJava7Compatible() ? "ant " : " class ") + "com.yahoo.documentapi.messagebus.protocol.DocumentProtocol" + (Util.isJava7Compatible() ? "." : "$") + "Priority.onkel_jubalon\"/>\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)

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