use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class DefaultTemplateSet method renderFieldContent.
protected void renderFieldContent(Context context, Hit hit, String name, XMLWriter writer) throws IOException {
boolean dumpedRaw = false;
if (hit instanceof FastHit && ((FastHit) hit).fieldIsNotDecoded(name)) {
writer.closeStartTag();
if ((writer.getWriter() instanceof ByteWriter) && context.isUtf8Output()) {
dumpedRaw = dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, name);
}
if (dumpedRaw) {
// let the xml writer note that this tag had content
writer.content("", false);
}
}
if (!dumpedRaw) {
String xmlval = hit.getFieldXML(name);
if (xmlval == null) {
xmlval = "(null)";
}
writer.escapedContent(xmlval, false);
}
}
use of com.yahoo.prelude.fastsearch.FastHit 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.prelude.fastsearch.FastHit 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.prelude.fastsearch.FastHit 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.FastHit in project vespa by vespa-engine.
the class CachingSearcherTestCase method readyResult.
public void readyResult(String q) {
Query query = new Query(q);
Result r = new Result(query);
for (int i = 0; i < 10; ++i) {
FastHit h = new FastHit("http://127.0.0.1/" + i, 1.0 - ((double) i) / 10.0);
r.hits().add(h);
}
hits.addResultSet(query, r);
}
Aggregations