use of com.yahoo.searchlib.aggregation.FS4Hit in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatHitHasContext.
@Test
public void requireThatHitHasContext() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
try {
converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3));
fail();
} catch (NullPointerException e) {
}
}
use of com.yahoo.searchlib.aggregation.FS4Hit in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatSummaryClassIsSet.
@Test
public void requireThatSummaryClassIsSet() {
Searcher searcher = new MySearcher();
HitConverter converter = new HitConverter(searcher, new Query());
Hit hit = converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3).setContext(new Hit("hit:ctx")));
assertNotNull(hit);
assertTrue(hit instanceof FastHit);
assertEquals("69", hit.getSearcherSpecificMetaData(searcher));
}
use of com.yahoo.searchlib.aggregation.FS4Hit in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatContextDataIsCopied.
@Test
public void requireThatContextDataIsCopied() {
Hit ctxHit = new Hit("hit:ctx");
ctxHit.setSource("69");
ctxHit.setSourceNumber(69);
Query ctxQuery = new Query();
ctxHit.setQuery(ctxQuery);
HitConverter converter = new HitConverter(new MySearcher(), new Query());
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(ctxHit));
assertNotNull(hit);
assertTrue(hit instanceof FastHit);
assertEquals(1, ((FastHit) hit).getPartId());
assertEquals(createGlobalId(2), ((FastHit) hit).getGlobalId());
assertSame(ctxQuery, hit.getQuery());
assertEquals(ctxHit.getSource(), hit.getSource());
assertEquals(ctxHit.getSourceNumber(), hit.getSourceNumber());
}
use of com.yahoo.searchlib.aggregation.FS4Hit in project vespa by vespa-engine.
the class HitConverter method convertFs4Hit.
private Hit convertFs4Hit(String summaryClass, FS4Hit groupHit) {
FastHit hit = new FastHit();
hit.setRelevance(groupHit.getRank());
hit.setGlobalId(groupHit.getGlobalId());
hit.setPartId(groupHit.getPath(), 0);
hit.setDistributionKey(groupHit.getDistributionKey());
hit.setFillable();
hit.setSearcherSpecificMetaData(searcher, summaryClass);
Hit ctxHit = (Hit) groupHit.getContext();
if (ctxHit == null) {
throw new NullPointerException("Hit has no context.");
}
hit.setSource(ctxHit.getSource());
hit.setSourceNumber(ctxHit.getSourceNumber());
hit.setQuery(ctxHit.getQuery());
if (ctxHit instanceof GroupingListHit) {
// in a live system the ctxHit can only by GroupingListHit, but because the code used Hit prior to version
// 5.10 we need to check to avoid breaking existing unit tests -- both internally and with customers
QueryPacketData queryPacketData = ((GroupingListHit) ctxHit).getQueryPacketData();
if (queryPacketData != null) {
hit.setQueryPacketData(queryPacketData);
}
}
return hit;
}
use of com.yahoo.searchlib.aggregation.FS4Hit in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatHitTagIsCopiedFromGroupingListContext.
@Test
public void requireThatHitTagIsCopiedFromGroupingListContext() {
QueryPacketData ctxTag = new QueryPacketData();
GroupingListHit ctxHit = new GroupingListHit(null, null);
ctxHit.setQueryPacketData(ctxTag);
HitConverter converter = new HitConverter(new MySearcher(), new Query());
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(ctxHit));
assertNotNull(hit);
assertTrue(hit instanceof FastHit);
assertSame(ctxTag, ((FastHit) hit).getQueryPacketData());
}
Aggregations