Search in sources :

Example 1 with QueryPacketData

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;
}
Also used : Query(com.yahoo.search.Query) ConfigurationException(com.yahoo.prelude.ConfigurationException) ConfigurationException(com.yahoo.prelude.ConfigurationException) IOException(java.io.IOException) DocumentInfo(com.yahoo.fs4.DocumentInfo)

Example 2 with QueryPacketData

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;
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) DocumentInfo(com.yahoo.fs4.DocumentInfo) Result(com.yahoo.search.Result)

Example 3 with QueryPacketData

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;
}
Also used : FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) Hit(com.yahoo.search.result.Hit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) QueryPacketData(com.yahoo.fs4.QueryPacketData) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit)

Example 4 with QueryPacketData

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());
}
Also used : FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) QueryPacketData(com.yahoo.fs4.QueryPacketData) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) Test(org.junit.Test)

Aggregations

DocumentInfo (com.yahoo.fs4.DocumentInfo)2 QueryPacketData (com.yahoo.fs4.QueryPacketData)2 FastHit (com.yahoo.prelude.fastsearch.FastHit)2 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)2 Query (com.yahoo.search.Query)2 Hit (com.yahoo.search.result.Hit)2 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)2 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)2 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)1 ConfigurationException (com.yahoo.prelude.ConfigurationException)1 Result (com.yahoo.search.Result)1 IOException (java.io.IOException)1 Test (org.junit.Test)1