Search in sources :

Example 1 with ResultBuilder

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

the class ResultBuilderTestCase method testSimpleResult.

public void testSimpleResult() {
    boolean gotErrorDetails = false;
    ResultBuilder r = new ResultBuilder();
    Result res = r.parse("file:src/test/java/com/yahoo/prelude/searcher/test/testhit.xml", new Query("?query=a"));
    assertEquals(3, res.getConcreteHitCount());
    assertEquals(4, res.getHitCount());
    ErrorHit e = (ErrorHit) res.hits().get(0);
    // is no way of nuking an existing error if the details exist.
    for (Iterator<?> i = e.errorIterator(); i.hasNext(); ) {
        ErrorMessage err = (ErrorMessage) i.next();
        assertEquals(5, err.getCode());
        String details = err.getDetailedMessage();
        if (details != null) {
            gotErrorDetails = true;
            assertEquals("An error as ordered", details.trim());
        }
    }
    assertTrue("Error details are missing", gotErrorDetails);
    assertEquals(new URI("http://def"), res.hits().get(1).getId());
    assertEquals("test/stuff\\tsome/other", res.hits().get(2).getField("category"));
    assertEquals("<field>habla</field>" + "<hi>blbl</hi><br />&lt;&gt;&amp;fdlkkgj&lt;/field&gt;;lk<a b=\"1\" c=\"2\" />" + "<x><y><z /></y></x>", res.hits().get(3).getField("annoying").toString());
}
Also used : ResultBuilder(com.yahoo.search.federation.vespa.ResultBuilder) Query(com.yahoo.search.Query) ErrorHit(com.yahoo.search.result.ErrorHit) ErrorMessage(com.yahoo.search.result.ErrorMessage) URI(com.yahoo.net.URI) Result(com.yahoo.search.Result)

Example 2 with ResultBuilder

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

the class ResultBuilderTestCase method testWeirdDocumentID.

public void testWeirdDocumentID() {
    ResultBuilder r = new ResultBuilder();
    Result res = r.parse("file:src/test/java/com/yahoo/search/federation/vespa/test/idhits.xml", new Query("?query=a"));
    assertNull(res.hits().getError());
    assertEquals(3, res.hits().size());
    assertEquals(new URI("nalle"), res.hits().get(0).getId());
    assertEquals(new URI("tralle"), res.hits().get(1).getId());
    assertEquals(new URI("kalle"), res.hits().get(2).getId());
}
Also used : ResultBuilder(com.yahoo.search.federation.vespa.ResultBuilder) Query(com.yahoo.search.Query) URI(com.yahoo.net.URI) Result(com.yahoo.search.Result)

Example 3 with ResultBuilder

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

the class ResultBuilderTestCase method testNestedResult.

public void testNestedResult() {
    ResultBuilder r = new ResultBuilder();
    Result res = r.parse("file:src/test/java/com/yahoo/search/federation/vespa/test/nestedhits.xml", new Query("?query=a"));
    assertNull(res.hits().getError());
    assertEquals(3, res.hits().size());
    assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", res.hits().get(0).getField("guid").toString());
    HitGroup g1 = (HitGroup) res.hits().get(1);
    HitGroup g2 = (HitGroup) res.hits().get(2);
    assertEquals(15, g1.size());
    assertEquals("reward_for_thumb", g1.get(1).getField("id").toString());
    assertEquals(10, g2.size());
    HitGroup g3 = (HitGroup) g2.get(3);
    assertEquals("badge", g3.getTypeString());
    assertEquals(2, g3.size());
    assertEquals("badge/Topic Explorer 5", g3.get(0).getField("name").toString());
}
Also used : ResultBuilder(com.yahoo.search.federation.vespa.ResultBuilder) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup)

Aggregations

Query (com.yahoo.search.Query)3 Result (com.yahoo.search.Result)3 ResultBuilder (com.yahoo.search.federation.vespa.ResultBuilder)3 URI (com.yahoo.net.URI)2 ErrorHit (com.yahoo.search.result.ErrorHit)1 ErrorMessage (com.yahoo.search.result.ErrorMessage)1 HitGroup (com.yahoo.search.result.HitGroup)1