Search in sources :

Example 6 with Coverage

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

the class JsonRendererTestCase method testCoverage.

@Test
public void testCoverage() throws InterruptedException, ExecutionException, IOException {
    String expected = "{\n" + "    \"root\": {\n" + "        \"coverage\": {\n" + "            \"coverage\": 83,\n" + "            \"documents\": 500,\n" + "            \"degraded\" : {\n" + "                \"match-phase\" : true,\n" + "                \"timeout\" : false,\n" + "                \"adaptive-timeout\" : true,\n" + "                \"non-ideal-state\" : false" + "            },\n" + "            \"full\": false,\n" + "            \"nodes\": 0,\n" + "            \"results\": 1,\n" + "            \"resultsFull\": 0\n" + "        },\n" + "        \"fields\": {\n" + "            \"totalCount\": 0\n" + "        },\n" + "        \"id\": \"toplevel\",\n" + "        \"relevance\": 1.0\n" + "    }\n" + "}";
    Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
    Execution execution = new Execution(Execution.Context.createContextStub());
    Result r = new Result(q);
    r.setCoverage(new Coverage(500, 600).setDegradedReason(5));
    String summary = render(execution, r);
    assertEqualJson(expected, summary);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Coverage(com.yahoo.search.result.Coverage) JSONString(com.yahoo.prelude.hitfield.JSONString) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 7 with Coverage

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

the class CoverageTestCase method testZeroCoverage.

public void testZeroCoverage() {
    Coverage c = new Coverage(0L, 0, false, 0);
    assertEquals(0, c.getResultPercentage());
    assertEquals(0, c.getResultSets());
}
Also used : Coverage(com.yahoo.search.result.Coverage)

Example 8 with Coverage

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

the class CoverageTestCase method testRequestingCoverageSearchScenario.

public void testRequestingCoverageSearchScenario() {
    boolean create = true;
    Result federationSearcherResult = new Result(new Query());
    Result singleSourceResult = new Result(new Query());
    singleSourceResult.setCoverage(new Coverage(10, 1, true));
    federationSearcherResult.mergeWith(singleSourceResult);
    assertEquals(1, federationSearcherResult.getCoverage(create).getResultSets());
}
Also used : Query(com.yahoo.search.Query) Coverage(com.yahoo.search.result.Coverage) Result(com.yahoo.search.Result)

Example 9 with Coverage

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

the class CoverageTestCase method testActiveCoverage.

public void testActiveCoverage() {
    Coverage c = new Coverage(6, 5);
    assertEquals(5, c.getActive());
    assertEquals(6, c.getDocs());
    Coverage d = new Coverage(7, 6);
    c.merge(d);
    assertEquals(11, c.getActive());
    assertEquals(13, c.getDocs());
}
Also used : Coverage(com.yahoo.search.result.Coverage)

Example 10 with Coverage

use of com.yahoo.search.result.Coverage 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)

Aggregations

Coverage (com.yahoo.search.result.Coverage)10 Result (com.yahoo.search.Result)6 Query (com.yahoo.search.Query)5 Test (org.junit.Test)4 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 HitGroup (com.yahoo.search.result.HitGroup)3 JSONString (com.yahoo.prelude.hitfield.JSONString)2 Searcher (com.yahoo.search.Searcher)2 Execution (com.yahoo.search.searchchain.Execution)2 CreativeTimeSource (com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource)2 UselessSearcher (com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher)2 TimeTracker (com.yahoo.search.statistics.TimeTracker)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)1 Metric (com.yahoo.jdisc.Metric)1 Grouping (com.yahoo.searchlib.aggregation.Grouping)1 BufferSerializer (com.yahoo.vespa.objects.BufferSerializer)1 ArrayList (java.util.ArrayList)1