Search in sources :

Example 41 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class GetSearcherTestCase method testDocumentFieldWithMultipleIDs.

@Test
public void testDocumentFieldWithMultipleIDs() 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&field=name"));
    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: Field only valid for single document id query\"/>\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 42 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class VisitorSearcherTestCase method testSimple.

@Test
public void testSimple() throws Exception {
    Chain<Searcher> searchChain = new Chain<>(create());
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("visit?visit.selection=id.user=1234&hits=100"));
    assertEquals(1, result.hits().size());
    assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<document documenttype=\"kittens\" documentid=\"userdoc:foo:1234:bar\"/>\n" + "</result>\n", result);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 43 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class SearchChainRegistry method setupSearcherRegistry.

private SearcherRegistry setupSearcherRegistry(ComponentRegistry<? extends AbstractComponent> allComponents) {
    SearcherRegistry registry = new SearcherRegistry();
    for (AbstractComponent component : allComponents.allComponents()) {
        if (component instanceof Searcher) {
            registry.register((Searcher) component);
        }
    }
    // just freeze this right away
    registry.freeze();
    return registry;
}
Also used : AbstractComponent(com.yahoo.component.AbstractComponent) Searcher(com.yahoo.search.Searcher)

Example 44 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class AsyncExecutionTestCase method testSync.

public void testSync() {
    Query query = new Query("?query=test");
    Searcher searcher = new ResultProducingSearcher();
    Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
    assertEquals(1, result.hits().size());
    assertEquals("hello", result.hits().get(0).getField("test"));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) AsyncExecution(com.yahoo.search.searchchain.AsyncExecution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FutureResult(com.yahoo.search.searchchain.FutureResult) Result(com.yahoo.search.Result)

Example 45 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class AsyncExecutionTestCase method testSyncThroughSync.

public void testSyncThroughSync() {
    Query query = new Query("?query=test");
    Searcher searcher = new ResultProducingSearcher();
    Result result = new Execution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
    assertEquals(1, result.hits().size());
    assertEquals("hello", result.hits().get(0).getField("test"));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) AsyncExecution(com.yahoo.search.searchchain.AsyncExecution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FutureResult(com.yahoo.search.searchchain.FutureResult) Result(com.yahoo.search.Result)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8