Search in sources :

Example 61 with Chain

use of com.yahoo.component.chain.Chain 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 62 with Chain

use of com.yahoo.component.chain.Chain 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 63 with Chain

use of com.yahoo.component.chain.Chain 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 64 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class FederationSearcherTestCase method testNoCloning.

@Test
public void testNoCloning() {
    String sourceName = "cloningcheck";
    Query query = new Query(QueryTestCase.httpEncode("?query=test&sources=" + sourceName));
    addChained(new QueryCheckSearcher(query), sourceName);
    addChained(new MockSearcher(), "mySource1");
    Chain<Searcher> mainChain = new Chain<>("default", createStrictFederationSearcher());
    Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
    HitGroup h = (HitGroup) result.hits().get(0);
    assertNull(h.getErrorHit());
    assertSame(QueryCheckSearcher.OK, h.get(0).getField(QueryCheckSearcher.STATUS));
    mainChain = new Chain<>("default", createFederationSearcher());
    result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
    h = (HitGroup) result.hits().get(0);
    assertSame(QueryCheckSearcher.FEDERATION_SEARCHER_HAS_CLONED_THE_QUERY, h.getError().getDetailedMessage());
    query = new Query(QueryTestCase.httpEncode("?query=test&sources=" + sourceName + ",mySource1"));
    addChained(new QueryCheckSearcher(query), sourceName);
    result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
    h = (HitGroup) result.hits().get(0);
    assertEquals("source:" + sourceName, h.getId().stringValue());
    assertSame(QueryCheckSearcher.FEDERATION_SEARCHER_HAS_CLONED_THE_QUERY, h.getError().getDetailedMessage());
    assertEquals("source:mySource1", result.hits().get(1).getId().stringValue());
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 65 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class FederationSearcherTestCase method testTopLevelHitGroupFieldPropagation.

@Test
public void testTopLevelHitGroupFieldPropagation() {
    addChained(new MockSearcher(), "mySource1");
    addChained(new AnotherMockSearcher(), "mySource2");
    Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
    Query q = new Query("?query=test");
    Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
    assertNull(result.hits().getError());
    assertEquals("source:mySource1", result.hits().get(0).getId().stringValue());
    assertEquals("source:mySource2", result.hits().get(1).getId().stringValue());
    assertEquals(AnotherMockSearcher.IS_THIS_PROPAGATED, result.hits().get(1).getField(AnotherMockSearcher.PROPAGATION_KEY));
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Chain (com.yahoo.component.chain.Chain)92 Execution (com.yahoo.search.searchchain.Execution)59 Searcher (com.yahoo.search.Searcher)57 Test (org.junit.Test)56 Result (com.yahoo.search.Result)48 Query (com.yahoo.search.Query)47 FeedContext (com.yahoo.feedapi.FeedContext)21 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)21 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)21 ClusterList (com.yahoo.vespaclient.ClusterList)21 Processor (com.yahoo.processing.Processor)17 Request (com.yahoo.processing.Request)10 Response (com.yahoo.processing.Response)10 ComponentId (com.yahoo.component.ComponentId)8 FederationSearcher (com.yahoo.search.federation.FederationSearcher)8 ArrayList (java.util.ArrayList)8 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 Message (com.yahoo.messagebus.Message)7 Hit (com.yahoo.search.result.Hit)7 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6