Search in sources :

Example 46 with Result

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

the class FederationSearcherTestCase method assertSelects.

private void assertSelects(String providerName, SearchChainRegistry registry) {
    QueryProfile profile = new QueryProfile("test");
    profile.set("source.news.provider", providerName, null);
    Query query = new Query(QueryTestCase.httpEncode("?query=test&model.sources=news"), profile.compile(null));
    Result result = new Execution(registry.getComponent("default"), Execution.Context.createContextStub(registry, null)).search(query);
    assertEquals(1, result.hits().size());
    assertNotNull(result.hits().get(providerName + ":1"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

Example 47 with Result

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

the class FederationSearcherTestCase method testDisablePropertyPropagation.

@Test
public void testDisablePropertyPropagation() {
    Result result = searchWithPropertyPropagation(PropagateSourceProperties.NONE);
    assertNull(result.hits().get(0).getQuery().getPresentation().getSummary());
}
Also used : Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 48 with Result

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

the class FederationSearcherTestCase method twoTracingSources.

private Chain<Searcher> twoTracingSources(boolean strictContracts) {
    addChained(new Searcher() {

        @Override
        public Result search(Query query, Execution execution) {
            query.trace(SOURCE1, 1);
            return execution.search(query);
        }
    }, SOURCE1);
    addChained(new Searcher() {

        @Override
        public Result search(Query query, Execution execution) {
            query.trace(SOURCE2, 1);
            return execution.search(query);
        }
    }, SOURCE2);
    Chain<Searcher> mainChain = new Chain<>("default", new FederationSearcher(new FederationConfig(builder), new StrictContractsConfig(new StrictContractsConfig.Builder().searchchains(strictContracts)), new ComponentRegistry<>()));
    return mainChain;
}
Also used : StrictContractsConfig(com.yahoo.search.federation.StrictContractsConfig) Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Query(com.yahoo.search.Query) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) FederationConfig(com.yahoo.search.federation.FederationConfig) Result(com.yahoo.search.Result)

Example 49 with Result

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

the class FederationSearcherTestCase method testTraceTwoSources.

@Test
public void testTraceTwoSources() {
    Chain<Searcher> mainChain = twoTracingSources(false);
    Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1"));
    Execution execution = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null));
    Result result = execution.search(q);
    assertNull(result.hits().getError());
    TwoSourceChecker lookForTraces = new TwoSourceChecker();
    execution.trace().accept(lookForTraces);
    assertTrue(lookForTraces.traceFromSource1);
    assertTrue(lookForTraces.traceFromSource2);
}
Also used : 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)

Example 50 with Result

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

the class GroupedResultTestCase method testGroupedResult.

public void testGroupedResult() {
    Result result = new Result(new Query("?query=foo"));
    HitGroup hitGroup1 = new HitGroup("group1", 300);
    hitGroup1.add(new Hit("group1.1", 200));
    HitGroup hitGroup2 = new HitGroup("group2", 600);
    Hit topLevelHit1 = new Hit("toplevel.1", 500);
    Hit topLevelHit2 = new Hit("toplevel.2", 700);
    result.hits().add(hitGroup1);
    result.hits().add(topLevelHit1);
    result.hits().add(hitGroup2);
    result.hits().add(topLevelHit2);
    hitGroup1.add(new Hit("group1.2", 800));
    hitGroup2.add(new Hit("group2.1", 800));
    hitGroup2.add(new Hit("group2.2", 300));
    hitGroup2.add(new Hit("group2.3", 500));
    // Should have 7 concrete hits, ordered as
    // toplevel.2
    // group2
    // group2.1
    // group2.3
    // group2.2
    // toplevel.1
    // group1
    // group1.2
    // group1.1
    // Assert this:
    assertEquals(7, result.getConcreteHitCount());
    assertEquals(4, result.getHitCount());
    Hit topLevel2 = result.hits().get(0);
    assertEquals("toplevel.2", topLevel2.getId().stringValue());
    HitGroup returnedGroup2 = (HitGroup) result.hits().get(1);
    assertEquals(3, returnedGroup2.getConcreteSize());
    assertEquals(3, returnedGroup2.size());
    assertEquals("group2.1", returnedGroup2.get(0).getId().stringValue());
    assertEquals("group2.3", returnedGroup2.get(1).getId().stringValue());
    assertEquals("group2.2", returnedGroup2.get(2).getId().stringValue());
    Hit topLevel1 = result.hits().get(2);
    assertEquals("toplevel.1", topLevel1.getId().stringValue());
    HitGroup returnedGroup1 = (HitGroup) result.hits().get(3);
    assertEquals(2, returnedGroup1.getConcreteSize());
    assertEquals(2, returnedGroup1.size());
    assertEquals("group1.2", returnedGroup1.get(0).getId().stringValue());
    assertEquals("group1.1", returnedGroup1.get(1).getId().stringValue());
}
Also used : Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup)

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