Search in sources :

Example 76 with Result

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

the class BlendingSearcherTestCase method testNonexistingBackendsCausesErrorOnFirst.

@Test
public void testNonexistingBackendsCausesErrorOnFirst() {
    // Feel free to change to include all in the detail message...
    BlendingSearcherWrapper searcher = setupFirstAndSecond();
    Query query = new Query("/search?query=banana&search=nonesuch,orsuch");
    Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
    assertEquals(0, result.getConcreteHitCount());
    assertNotNull(result.hits().getError());
    ErrorMessage e = result.hits().getError();
    assertEquals("Invalid query parameter", e.getMessage());
    // TODO: Do not depend on sources order
    assertEquals("4: Invalid query parameter: Could not resolve source ref 'nonesuch'. Could not resolve source ref 'orsuch'. Valid source refs are first, second.", e.toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 77 with Result

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

the class FederationSearcherTest method require_that_hits_can_be_filled_for_multiple_chains_and_queries.

@Test
public void require_that_hits_can_be_filled_for_multiple_chains_and_queries() {
    FederationTester tester = new FederationTester();
    tester.addSearchChain("chain1", new AddHitSearcher());
    tester.addSearchChain("chain2", new ModifyQueryAndAddHitSearcher("modified1"));
    tester.addSearchChain("chain3", new ModifyQueryAndAddHitSearcher("modified2"));
    Result result = tester.search();
    tester.fill(result);
    assertEquals(3, result.hits().getConcreteSize());
    for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext(); ) assertFilled(i.next());
}
Also used : ErrorHit(com.yahoo.search.result.ErrorHit) Hit(com.yahoo.search.result.Hit) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 78 with Result

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

the class FederationSearcherTest method require_that_optional_search_chains_does_not_delay_federation.

@Test
public void require_that_optional_search_chains_does_not_delay_federation() {
    BlockingSearcher blockingSearcher = new BlockingSearcher();
    FederationTester tester = new FederationTester();
    tester.addSearchChain("chain1", new AddHitSearcher());
    tester.addOptionalSearchChain("chain2", blockingSearcher);
    Result result = tester.searchAndFill();
    assertThat(getNonErrorHits(result).size(), is(1));
    assertFilled(getFirstHit(getNonErrorHits(result).get(0)));
    assertNotNull(result.hits().getError());
}
Also used : Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 79 with Result

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

the class FederationSearcherTest method require_that_hits_can_be_filled_when_moved.

@Test
public void require_that_hits_can_be_filled_when_moved() {
    FederationTester tester = new FederationTester();
    tester.addSearchChain("chain1", new AddHitSearcher());
    tester.addSearchChain("chain2", new AddHitSearcher());
    Result result = tester.search();
    Result reorganizedResult = new Result(result.getQuery());
    HitGroup hit1 = new HitGroup();
    HitGroup nestedHitGroup = new HitGroup();
    hit1.add(nestedHitGroup);
    reorganizedResult.hits().add(hit1);
    HitGroup chain1Group = (HitGroup) result.hits().get(0);
    HitGroup chain2Group = (HitGroup) result.hits().get(1);
    nestedHitGroup.add(chain1Group.get(0));
    reorganizedResult.hits().add(chain2Group.get(0));
    reorganizedResult.hits().add(nestedHitGroup);
    tester.fill(reorganizedResult);
    assertFilled(nestedHitGroup.get(0));
    assertFilled(chain2Group.get(0));
}
Also used : Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 80 with Result

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

the class FederationSearcherTest method require_that_hits_are_not_automatically_filled.

@Test
public void require_that_hits_are_not_automatically_filled() {
    Result result = federationToSingleAddHitSearcher().search();
    assertNotFilled(firstHitInFirstGroup(result));
}
Also used : Result(com.yahoo.search.Result) Test(org.junit.Test)

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