Search in sources :

Example 41 with Query

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

the class TwoSectionsFourSourcesTestCase method testExecutionMissingTwoSources.

@Test
public void testExecutionMissingTwoSources() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    result.hits().add(createHits("source1", 3));
    result.hits().add(createHits("source3", 12));
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertGroupedSource3Source1(section1.asList());
    assertEquals(0, section2.size());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 42 with Query

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

the class TwoSectionsFourSourcesTestCase method testExecutionMissingAllSources.

@Test
public void testExecutionMissingAllSources() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertEquals(0, section1.size());
    assertEquals(0, section2.size());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 43 with Query

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

the class TwoSectionsFourSourcesTestCase method testExecutionMissingOneSource.

@Test
public void testExecutionMissingOneSource() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    result.hits().add(createHits("source1", 3));
    result.hits().add(createHits("source3", 12));
    result.hits().add(createHits("source4", 13));
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertGroupedSource3Source1(section1.asList());
    assertEqualHitGroups(createHits("source4", 10), section2);
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 44 with Query

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

the class TwoSectionsFourSourcesTestCase method testExecution.

@Test
public void testExecution() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    result.hits().add(createHits("source1", 3));
    result.hits().add(createHits("source2", 4));
    result.hits().add(createHits("source3", 12));
    result.hits().add(createHits("source4", 13));
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertGroupedSource3Source1(section1.asList());
    assertBlendedSource4Source2(section2.asList());
    // Check rendering
    assertRendered(result, "TwoSectionsFourSourcesResult.xml");
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 45 with Query

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

the class SoftTimeoutTestCase method testQueryOverride.

@Test
public void testQueryOverride() {
    Query query = new Query("?query=test&ranking.softtimeout.enable&ranking.softtimeout.factor=0.7&ranking.softtimeout.tailcost=0.3");
    assertTrue(query.getRanking().getSoftTimeout().getEnable());
    assertEquals(Double.valueOf(0.7), query.getRanking().getSoftTimeout().getFactor());
    assertEquals(Double.valueOf(0.3), query.getRanking().getSoftTimeout().getTailcost());
    query.prepare();
    assertEquals("true", query.getRanking().getProperties().get("vespa.softtimeout.enable").get(0));
    assertEquals("0.7", query.getRanking().getProperties().get("vespa.softtimeout.factor").get(0));
    assertEquals("0.3", query.getRanking().getProperties().get("vespa.softtimeout.tailcost").get(0));
}
Also used : Query(com.yahoo.search.Query) Test(org.junit.Test)

Aggregations

Query (com.yahoo.search.Query)689 Test (org.junit.Test)415 Result (com.yahoo.search.Result)229 Execution (com.yahoo.search.searchchain.Execution)184 Searcher (com.yahoo.search.Searcher)82 QueryProfile (com.yahoo.search.query.profile.QueryProfile)63 Hit (com.yahoo.search.result.Hit)52 Chain (com.yahoo.component.chain.Chain)47 IndexFacts (com.yahoo.prelude.IndexFacts)44 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)37 AndItem (com.yahoo.prelude.query.AndItem)33 WordItem (com.yahoo.prelude.query.WordItem)33 FastHit (com.yahoo.prelude.fastsearch.FastHit)31 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)27 HitGroup (com.yahoo.search.result.HitGroup)24 Item (com.yahoo.prelude.query.Item)21 HashMap (java.util.HashMap)20 CacheKey (com.yahoo.prelude.fastsearch.CacheKey)18 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)18 ArrayList (java.util.ArrayList)18