Search in sources :

Example 21 with FeedContext

use of com.yahoo.feedapi.FeedContext 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 22 with FeedContext

use of com.yahoo.feedapi.FeedContext 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)

Example 23 with FeedContext

use of com.yahoo.feedapi.FeedContext in project vespa by vespa-engine.

the class GetSearcherTestCase method testJsonRendererSetting.

@Test
public void testJsonRendererSetting() 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);
    Query query = newQuery("?id=userdoc:kittens:1:2&format=json");
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
    assertFalse(result.getTemplating().getTemplates() instanceof DocumentXMLTemplate);
}
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 24 with FeedContext

use of com.yahoo.feedapi.FeedContext in project vespa by vespa-engine.

the class VisitorSearcherTestCase method create.

public VisitSearcher create() throws Exception {
    ClusterListConfig.Storage.Builder storageCluster = new ClusterListConfig.Storage.Builder().configid("storage/cluster.foobar").name("foobar");
    ClusterListConfig clusterListCfg = new ClusterListConfig(new ClusterListConfig.Builder().storage(storageCluster));
    ClusterList clusterList = new ClusterList(clusterListCfg);
    return new VisitSearcher(new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder().timeout(458).route("riksveg18").retryenabled(true)), new LoadTypeConfig(new LoadTypeConfig.Builder())), factory, docMan, clusterList, new NullFeedMetric()));
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) FeedContext(com.yahoo.feedapi.FeedContext) ClusterListConfig(com.yahoo.cloud.config.ClusterListConfig) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) LoadTypeConfig(com.yahoo.vespa.config.content.LoadTypeConfig)

Example 25 with FeedContext

use of com.yahoo.feedapi.FeedContext in project vespa by vespa-engine.

the class VespaFeeder method parseFiles.

void parseFiles(InputStream stdin, PrintStream output) throws Exception {
    FeedContext context = new FeedContext(args.getPropertyProcessor(), args.getSessionFactory(), manager, new ClusterList(), new NullFeedMetric());
    final BufferedInputStream input = new BufferedInputStream(stdin);
    VespaFeedHandler handler = VespaFeedHandler.createFromContext(context, threadPool);
    if (args.getFiles().isEmpty()) {
        InputStreamRequest req = new InputStreamRequest(input);
        setProperties(req, input);
        FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
        if (!response.isSuccess()) {
            throw renderErrors(response.getErrorList());
        }
    } else {
        if (args.isVerbose()) {
            for (String fileName : args.getFiles()) {
                long thisSize = new File(fileName).length();
                output.println("Size of file '" + fileName + "' is " + thisSize + " B.");
            }
        }
        for (String fileName : args.getFiles()) {
            File f = new File(fileName);
            FileRequest req = new FileRequest(f);
            final BufferedInputStream inputSnooper = new BufferedInputStream(new FileInputStream(fileName));
            setProperties(req, inputSnooper);
            inputSnooper.close();
            FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
            if (!response.isSuccess()) {
                throw renderErrors(response.getErrorList());
            }
        }
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) FeedContext(com.yahoo.feedapi.FeedContext) VespaFeedHandler(com.yahoo.feedhandler.VespaFeedHandler) FeedResponse(com.yahoo.feedhandler.FeedResponse) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric)

Aggregations

FeedContext (com.yahoo.feedapi.FeedContext)25 ClusterList (com.yahoo.vespaclient.ClusterList)25 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)24 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)24 Chain (com.yahoo.component.chain.Chain)21 Test (org.junit.Test)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)7 Message (com.yahoo.messagebus.Message)7 FeederConfig (com.yahoo.vespaclient.config.FeederConfig)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 ComponentId (com.yahoo.component.ComponentId)1 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)1