Search in sources :

Example 1 with Hit

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);
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup) Result(com.yahoo.search.Result)

Example 2 with Hit

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);
    }
}
Also used : Hit(com.yahoo.search.result.Hit) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) XMLString(com.yahoo.prelude.hitfield.XMLString) Result(com.yahoo.search.Result)

Example 3 with Hit

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;
            }
        }
    }
}
Also used : Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 4 with Hit

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);
        }
    }
}
Also used : Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 5 with Hit

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;
}
Also used : ErrorHit(com.yahoo.search.result.ErrorHit) Hit(com.yahoo.search.result.Hit) DocsumPacket(com.yahoo.fs4.DocsumPacket) Query(com.yahoo.search.Query)

Aggregations

Hit (com.yahoo.search.result.Hit)127 Result (com.yahoo.search.Result)72 Query (com.yahoo.search.Query)52 FastHit (com.yahoo.prelude.fastsearch.FastHit)42 Test (org.junit.Test)41 Execution (com.yahoo.search.searchchain.Execution)25 HitGroup (com.yahoo.search.result.HitGroup)21 Searcher (com.yahoo.search.Searcher)17 JSONString (com.yahoo.prelude.hitfield.JSONString)13 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)12 ErrorHit (com.yahoo.search.result.ErrorHit)10 Relevance (com.yahoo.search.result.Relevance)10 HashMap (java.util.HashMap)9 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)8 Group (com.yahoo.search.grouping.result.Group)8 ComponentId (com.yahoo.component.ComponentId)7 Chain (com.yahoo.component.chain.Chain)7 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)6 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)6 GroupList (com.yahoo.search.grouping.result.GroupList)5