Search in sources :

Example 1 with Result

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

the class ApplicationTest method container_and_referenced_content.

/**
 * Tests that an application with search chains referencing a content cluster can be constructed.
 */
@Test
public void container_and_referenced_content() throws Exception {
    try (Application application = Application.fromApplicationPackage(new File("src/test/app-packages/withcontent"), Networking.disable)) {
        Result result = application.getJDisc("default").search().process(new ComponentSpecification("default"), new Query("?query=substring:foobar&tracelevel=3"));
        assertEquals("AND substring:fo substring:oo substring:ob substring:ba substring:ar", result.hits().get("hasQuery").getQuery().getModel().getQueryTree().toString());
    }
}
Also used : Query(com.yahoo.search.Query) ComponentSpecification(com.yahoo.component.ComponentSpecification) File(java.io.File) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 2 with Result

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

the class ApplicationTest method search_default.

@Test
public void search_default() throws Exception {
    try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container().searcher(MockSearcher.class))))) {
        Result result = app.search(new Query("?query=foo"));
        assertEquals(1, result.hits().size());
    }
}
Also used : MockSearcher(com.yahoo.application.container.searchers.MockSearcher) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 3 with Result

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

the class ApplicationTest method search.

@Test
public void search() throws Exception {
    try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container().searcher("foo", MockSearcher.class))))) {
        Result result = app.search("foo", new Query("?query=foo"));
        assertEquals(1, result.hits().size());
    }
}
Also used : MockSearcher(com.yahoo.application.container.searchers.MockSearcher) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 4 with Result

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

the class Search method doProcessAndRender.

@Override
@SuppressWarnings("deprecation")
protected ListenableFuture<Boolean> doProcessAndRender(ComponentSpecification chainSpec, Query request, Renderer<Result> renderer, ByteArrayOutputStream stream) throws IOException {
    Result result = process(chainSpec, request);
    result.getTemplating().setRenderer(renderer);
    return HttpSearchResponse.waitableRender(result, result.getQuery(), renderer, stream);
}
Also used : Result(com.yahoo.search.Result)

Example 5 with Result

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

the class MockSearcher method search.

@Override
public Result search(Query query, Execution execution) {
    HitGroup hits = new HitGroup();
    hits.add(new Hit("foo", query));
    return new Result(query, hits);
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup) Result(com.yahoo.search.Result)

Aggregations

Result (com.yahoo.search.Result)398 Test (org.junit.Test)231 Query (com.yahoo.search.Query)229 Execution (com.yahoo.search.searchchain.Execution)127 Searcher (com.yahoo.search.Searcher)94 Hit (com.yahoo.search.result.Hit)72 Chain (com.yahoo.component.chain.Chain)48 FastHit (com.yahoo.prelude.fastsearch.FastHit)36 HitGroup (com.yahoo.search.result.HitGroup)29 JSONString (com.yahoo.prelude.hitfield.JSONString)26 HashMap (java.util.HashMap)21 FeedContext (com.yahoo.feedapi.FeedContext)19 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)19 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)19 ClusterList (com.yahoo.vespaclient.ClusterList)19 ErrorMessage (com.yahoo.search.result.ErrorMessage)17 Choice (com.yahoo.search.pagetemplates.model.Choice)16 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)15 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)15 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)14