use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class MockSearcher method search.
@Override
public Result search(Query query, Execution execution) {
HitGroup hits = new HitGroup();
hits.add(new Hit("foo", query));
return new Result(query, hits);
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class SimpleSearcher method search.
public Result search(Query query, Execution execution) {
try {
BooleanParser.parseBoolean("true");
XMLString xmlString = new XMLString("<sampleXmlString/>");
Hit hit = new Hit("Hello world!");
hit.setField("json", new JSONObject().put("price", 42).toString());
Result result = execution.search(query);
result.hits().add(hit);
return result;
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class GetDocSumsPacket method setFieldsFromHits.
private void setFieldsFromHits() {
for (Iterator<Hit> i = result.hits().unorderedDeepIterator(); i.hasNext(); ) {
Hit h = i.next();
if (h instanceof FastHit) {
FastHit hit = (FastHit) h;
if (hit.shouldIgnoreRowBits()) {
flags |= GDFLAG_IGNORE_ROW;
}
QueryPacketData tag = hit.getQueryPacketData();
if (tag != null) {
this.queryPacketData = tag;
break;
}
}
}
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class GetDocSumsPacket method encodeDocIds.
private void encodeDocIds(ByteBuffer buffer) {
byte[] emptyGid = new byte[GlobalId.LENGTH];
for (Iterator<Hit> i = result.hits().unorderedDeepIterator(); i.hasNext(); ) {
Hit hit = i.next();
if (hit instanceof FastHit && !hit.isFilled(summaryClass)) {
FastHit fastHit = (FastHit) hit;
buffer.put(fastHit.getGlobalId() != null ? fastHit.getGlobalId().getRawId() : emptyGid);
buffer.putInt(fastHit.getPartId());
// Unused, was docstamp
buffer.putInt(0);
}
}
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class VespaBackEndSearcher method cacheLookupTwoPhase.
protected PacketWrapper cacheLookupTwoPhase(CacheKey cacheKey, Result result, String summaryClass) {
Query query = result.getQuery();
PacketWrapper packetWrapper = cacheControl.lookup(cacheKey, query);
if (packetWrapper == null) {
return null;
}
if (packetWrapper.getNumPackets() != 0) {
for (Iterator<Hit> i = hitIterator(result); i.hasNext(); ) {
Hit hit = i.next();
if (hit instanceof FastHit) {
FastHit fastHit = (FastHit) hit;
DocsumPacketKey key = new DocsumPacketKey(fastHit.getGlobalId(), fastHit.getPartId(), summaryClass);
if (fillHit(fastHit, (DocsumPacket) packetWrapper.getPacket(key), summaryClass).ok) {
fastHit.setCached(true);
}
}
}
result.hits().setSorted(false);
result.analyzeHits();
}
return packetWrapper;
}
Aggregations