Search in sources :

Example 36 with HitGroup

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

the class XMLRendererTestCase method testImplicitDefaultRender.

@Test
public final void testImplicitDefaultRender() throws Exception {
    Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
    q.getPresentation().setTiming(true);
    Result r = new Result(q);
    r.setCoverage(new Coverage(500, 1, true));
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L }));
    t.sampleSearch(0, true);
    t.sampleSearch(1, true);
    t.sampleSearch(2, true);
    t.sampleSearch(3, true);
    t.sampleSearchReturn(2, true, null);
    t.sampleSearchReturn(1, true, null);
    t.sampleSearchReturn(0, true, null);
    r.getElapsedTime().add(t);
    r.getTemplating().setRenderer(d);
    FastHit h = new FastHit("http://localhost/", .95);
    h.setField("$a", "Hello, world.");
    h.setField("b", "foo");
    r.hits().add(h);
    HitGroup g = new HitGroup("usual");
    h = new FastHit("http://localhost/1", .90);
    h.setField("c", "d");
    g.add(h);
    r.hits().add(g);
    HitGroup gg = new HitGroup("type grouphit");
    gg.types().add("grouphit");
    gg.setField("e", "f");
    r.hits().add(gg);
    r.hits().addError(ErrorMessage.createInternalServerError("boom"));
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    ListenableFuture<Boolean> f = d.render(bs, r, null, null);
    assertTrue(f.get());
    String summary = Utf8.toString(bs.toByteArray());
    assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<result total-hit-count=\"0\"", summary.substring(0, 67));
    assertTrue(summary.contains("<meta type=\"context\">"));
    assertTrue(summary.contains("<error code=\"18\">Internal server error.</error>"));
    assertTrue(summary.contains("<hit type=\"grouphit\" relevancy=\"1.0\">"));
    assertTrue(summary.contains("<hit type=\"summary\" relevancy=\"0.95\">"));
    assertEquals(2, occurrences("<error ", summary));
    assertTrue(summary.length() > 1000);
}
Also used : Query(com.yahoo.search.Query) CreativeTimeSource(com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource) Searcher(com.yahoo.search.Searcher) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) Coverage(com.yahoo.search.result.Coverage) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Result(com.yahoo.search.Result) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) FastHit(com.yahoo.prelude.fastsearch.FastHit) TimeTracker(com.yahoo.search.statistics.TimeTracker) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 37 with HitGroup

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

the class DeepHitIteratorTestCase method testOrder.

public void testOrder() {
    HitGroup root = new HitGroup();
    MyHitGroup group = new MyHitGroup();
    group.add(new Hit("foo"));
    root.add(group);
    Iterator<Hit> it = root.deepIterator();
    assertTrue(it.hasNext());
    assertEquals("foo", it.next().getId().toString());
    assertEquals(Boolean.TRUE, group.ordered);
    assertFalse(it.hasNext());
    it = root.unorderedDeepIterator();
    assertTrue(it.hasNext());
    assertEquals("foo", it.next().getId().toString());
    assertEquals(Boolean.FALSE, group.ordered);
    assertFalse(it.hasNext());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 38 with HitGroup

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

the class DeepHitIteratorTestCase method testShallow.

public void testShallow() {
    HitGroup hits = new HitGroup();
    hits.add(new Hit("foo"));
    hits.add(new Hit("bar"));
    hits.add(new Hit("baz"));
    Iterator<Hit> it = hits.deepIterator();
    assertTrue(it.hasNext());
    assertEquals("foo", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("bar", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("baz", it.next().getId().toString());
    assertFalse(it.hasNext());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 39 with HitGroup

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

the class FillingTestCase method testFillingAPIConsistency.

public void testFillingAPIConsistency() {
    HitGroup group = new HitGroup();
    group.add(new Hit("hit:1"));
    group.add(new Hit("hit:2"));
    assertTrue(group.isFilled("summary"));
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 40 with HitGroup

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

the class MultipleResultsTestCase method testRetrieveHeterogenousHits.

@Test
public void testRetrieveHeterogenousHits() {
    Query query = createQuery();
    Result originalResult = new Result(query);
    int n1 = 15, n2 = 25, n3 = 25, n4 = 25;
    addHits(originalResult, "others", n1);
    addHits(originalResult, "music", n2);
    addHits(originalResult, "movies", n3);
    addHits(originalResult, "others", n4);
    originalResult.setTotalHitCount(n1 + n2 + n3 + n4);
    docSource.addResult(query, originalResult);
    query.setWindow(0, 30);
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
    HitGroup musicGroup = (HitGroup) result.hits().get("music");
    HitGroup moviesGroup = (HitGroup) result.hits().get("movies");
    assertEquals(15, musicGroup.size());
    assertEquals(15, moviesGroup.size());
    assertEquals(3, docSource.getQueryCount());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Aggregations

HitGroup (com.yahoo.search.result.HitGroup)48 Test (org.junit.Test)28 Result (com.yahoo.search.Result)27 Query (com.yahoo.search.Query)24 Hit (com.yahoo.search.result.Hit)21 Execution (com.yahoo.search.searchchain.Execution)11 Searcher (com.yahoo.search.Searcher)8 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)8 Choice (com.yahoo.search.pagetemplates.model.Choice)8 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)7 DefaultErrorHit (com.yahoo.search.result.DefaultErrorHit)6 Chain (com.yahoo.component.chain.Chain)5 ErrorHit (com.yahoo.search.result.ErrorHit)4 ComponentId (com.yahoo.component.ComponentId)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 FederationSearcher (com.yahoo.search.federation.FederationSearcher)3 Resolution (com.yahoo.search.pagetemplates.engine.Resolution)3 Resolver (com.yahoo.search.pagetemplates.engine.Resolver)3 Coverage (com.yahoo.search.result.Coverage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3