Search in sources :

Example 1 with DocsumDefinitionSet

use of com.yahoo.prelude.fastsearch.DocsumDefinitionSet in project vespa by vespa-engine.

the class HitConverterTestCase method requireThatVdsHitCanBeConverted.

@Test
public void requireThatVdsHitCanBeConverted() {
    HitConverter converter = new HitConverter(new MySearcher(), new Query());
    GroupingListHit context = new GroupingListHit(null, new DocsumDefinitionSet(sixtynine()));
    VdsHit lowHit = new VdsHit("doc:scheme:", new byte[] { 0x55, 0x55, 0x55, 0x55 }, 1);
    lowHit.setContext(context);
    Hit hit = converter.toSearchHit("69", lowHit);
    assertNotNull(hit);
    assertTrue(hit instanceof FastHit);
    assertEquals(new Relevance(1), hit.getRelevance());
    assertTrue(hit.isFilled("69"));
}
Also used : Relevance(com.yahoo.search.result.Relevance) FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) Test(org.junit.Test)

Example 2 with DocsumDefinitionSet

use of com.yahoo.prelude.fastsearch.DocsumDefinitionSet in project vespa by vespa-engine.

the class HitConverter method convertVdsHit.

private Hit convertVdsHit(String summaryClass, VdsHit grpHit) {
    FastHit ret = new FastHit();
    ret.setRelevance(grpHit.getRank());
    if (grpHit.getSummary().getData().length > 0) {
        GroupingListHit ctxHit = (GroupingListHit) grpHit.getContext();
        if (ctxHit == null) {
            throw new NullPointerException("Hit has no context.");
        }
        DocsumDefinitionSet defs = ctxHit.getDocsumDefinitionSet();
        defs.lazyDecode(summaryClass, grpHit.getSummary().getData(), ret);
        ret.setFilled(summaryClass);
        ret.setFilled(query.getPresentation().getSummary());
    }
    return ret;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit)

Example 3 with DocsumDefinitionSet

use of com.yahoo.prelude.fastsearch.DocsumDefinitionSet in project vespa by vespa-engine.

the class DocsumDefinitionTestCase method testReading.

@Test
public void testReading() {
    String summary_cf = "file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg";
    DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf);
    String[] defs = new String[] { "[default,default]", "[version1,version1]", "[withranklog,withranklog]", "[version2,version2]", "[version3,version3]", "[version4,version4]", "[version5,version5]" };
    String setAsString = set.toString();
    for (String d : defs) {
        assertFalse(setAsString.indexOf(d) == -1);
    }
    assertEquals(7, set.size());
    DocsumDefinition docsum0 = set.getDocsumDefinition("default");
    assertNotNull(docsum0);
    assertEquals("default", docsum0.getName());
    assertEquals(19, docsum0.getFieldCount());
    assertNull(docsum0.getField(19));
    assertEquals("DSHOST", docsum0.getField(7).getName());
    assertTrue(docsum0.getField(1) instanceof StringField);
    assertTrue(docsum0.getField(6) instanceof ByteField);
    assertTrue(docsum0.getField(7) instanceof IntegerField);
    assertTrue(docsum0.getField(18) instanceof DataField);
}
Also used : DataField(com.yahoo.prelude.fastsearch.DataField) StringField(com.yahoo.prelude.fastsearch.StringField) DocsumDefinition(com.yahoo.prelude.fastsearch.DocsumDefinition) ByteField(com.yahoo.prelude.fastsearch.ByteField) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) IntegerField(com.yahoo.prelude.fastsearch.IntegerField) Test(org.junit.Test)

Example 4 with DocsumDefinitionSet

use of com.yahoo.prelude.fastsearch.DocsumDefinitionSet in project vespa by vespa-engine.

the class DocsumDefinitionTestCase method testDecoding.

@Test
public void testDecoding() {
    String summary_cf = "file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg";
    DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf);
    FastHit hit = new FastHit();
    set.lazyDecode(null, makeDocsum(), hit);
    assertEquals("Arts/Celebrities/Madonna", hit.getField("TOPIC"));
    assertEquals("1", hit.getField("EXTINFOSOURCE").toString());
    assertEquals("10", hit.getField("LANG1").toString());
    assertEquals("352", hit.getField("WORDS").toString());
    assertEquals("index:0/0/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) Test(org.junit.Test)

Aggregations

DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)4 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 Test (org.junit.Test)3 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)2 ByteField (com.yahoo.prelude.fastsearch.ByteField)1 DataField (com.yahoo.prelude.fastsearch.DataField)1 DocsumDefinition (com.yahoo.prelude.fastsearch.DocsumDefinition)1 IntegerField (com.yahoo.prelude.fastsearch.IntegerField)1 StringField (com.yahoo.prelude.fastsearch.StringField)1 Query (com.yahoo.search.Query)1 Hit (com.yahoo.search.result.Hit)1 Relevance (com.yahoo.search.result.Relevance)1 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)1 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)1