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"));
}
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;
}
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);
}
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());
}
Aggregations