use of com.yahoo.fs4.QueryPacketData in project vespa by vespa-engine.
the class VespaBackEndSearcher method addUnfilledHits.
/**
* Creates unfilled hits from a List of DocumentInfo instances. Do note
* cacheKey should be available if a cache is active, even if the hit is not
* created from a cache in the current call path.
*
* @param queryPacketData binary data from first phase of search, or null
* @param cacheKey the key this hit should match in the packet cache, or null
*/
protected boolean addUnfilledHits(Result result, List<DocumentInfo> documents, boolean fromCache, QueryPacketData queryPacketData, CacheKey cacheKey) {
boolean allHitsOK = true;
Query myQuery = result.getQuery();
for (DocumentInfo document : documents) {
try {
FastHit hit = new FastHit();
hit.setQuery(myQuery);
if (queryPacketData != null)
hit.setQueryPacketData(queryPacketData);
hit.setCacheKey(cacheKey);
hit.setUseRowInIndexUri(useRowInIndexUri(result));
hit.setFillable();
hit.setCached(fromCache);
extractDocumentInfo(hit, document);
result.hits().add(hit);
} catch (ConfigurationException e) {
allHitsOK = false;
getLogger().log(LogLevel.WARNING, "Skipping hit", e);
} catch (Exception e) {
allHitsOK = false;
getLogger().log(LogLevel.ERROR, "Skipping malformed hit", e);
}
}
return allHitsOK;
}
use of com.yahoo.fs4.QueryPacketData in project vespa by vespa-engine.
the class VespaBackEndSearcher method cacheLookupFirstPhase.
private Result cacheLookupFirstPhase(CacheKey key, QueryPacketData queryPacketData, Query query, int offset, int hits, String summaryClass) {
PacketWrapper packetWrapper = cacheControl.lookup(key, query);
if (packetWrapper == null)
return null;
// Check if the cache entry contains the requested hits
List<DocumentInfo> documents = packetWrapper.getDocuments(offset, hits);
if (documents == null)
return null;
if (query.getPresentation().getSummary() == null)
query.getPresentation().setSummary(getDefaultDocsumClass());
Result result = new Result(query);
QueryResultPacket resultPacket = packetWrapper.getFirstResultPacket();
addMetaInfo(query, queryPacketData, resultPacket, result, true);
if (packetWrapper.getNumPackets() == 0)
addUnfilledHits(result, documents, true, queryPacketData, key);
else
addCachedHits(result, packetWrapper, summaryClass, documents);
return result;
}
use of com.yahoo.fs4.QueryPacketData 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.fs4.QueryPacketData 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