Search in sources :

Example 31 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class DefaultRenderer method renderField.

private void renderField(XMLWriter writer, Hit hit, Iterator<Map.Entry<String, Object>> it) throws IOException {
    Map.Entry<String, Object> entry = it.next();
    boolean isProbablyNotDecoded = false;
    if (hit instanceof FastHit) {
        FastHit f = (FastHit) hit;
        isProbablyNotDecoded = f.fieldIsNotDecoded(entry.getKey());
    }
    renderGenericFieldPossiblyNotDecoded(writer, hit, entry, isProbablyNotDecoded);
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Utf8String(com.yahoo.text.Utf8String) Map(java.util.Map) CopyOnWriteHashMap(com.yahoo.concurrent.CopyOnWriteHashMap)

Example 32 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class JsonRenderer method tryDirectRendering.

/**
 * Really a private method, but package access for testability.
 */
boolean tryDirectRendering(String fieldName, Hit hit) throws IOException {
    boolean renderedAsUtf8 = false;
    if (hit instanceof FastHit) {
        FastHit f = (FastHit) hit;
        if (f.fieldIsNotDecoded(fieldName)) {
            FastHit.RawField r = f.fetchFieldAsUtf8(fieldName);
            if (r != null) {
                byte[] utf8 = r.getUtf8();
                generator.writeUTF8String(utf8, 0, utf8.length);
                renderedAsUtf8 = true;
            }
        }
    }
    return renderedAsUtf8;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 33 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class VdsStreamingSearcher method buildSummaryHit.

private FastHit buildSummaryHit(Query query, SearchResult.Hit hit) {
    FastHit fastHit = new FastHit();
    fastHit.setQuery(query);
    fastHit.setSource(getName());
    fastHit.setId(hit.getDocId());
    fastHit.setRelevance(new Relevance(hit.getRank()));
    fastHit.setFillable();
    return fastHit;
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 34 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class GetDocSumsPacketTestCase method requireThatSessionIdIsEncodedAsPropertyWhenUsingSearchSession.

@Test
public void requireThatSessionIdIsEncodedAsPropertyWhenUsingSearchSession() throws BufferTooSmallException {
    Result result = new Result(new Query("?query=foo"));
    // create session id.
    SessionId sessionId = result.getQuery().getSessionId(true);
    result.getQuery().getRanking().setQueryCache(true);
    FastHit hit = new FastHit();
    result.hits().add(hit);
    ByteBuffer answer = ByteBuffer.allocate(1024);
    // assertEquals(0, sessionId.asUtf8String().getByteLength());
    answer.put(new byte[] { 0, 0, 0, (byte) (107 + sessionId.asUtf8String().getByteLength()), 0, 0, 0, -37, 0, 0, 56, 17, 0, 0, 0, 0, // query timeout
    IGNORE, IGNORE, IGNORE, IGNORE, // "default" - rank profile
    7, 'd', 'e', 'f', 'a', 'u', 'l', 't', 0, 0, 0, 0x03, // "default" - summaryclass
    0, 0, 0, 7, 'd', 'e', 'f', 'a', 'u', 'l', 't', // 2 property entries
    0, 0, 0, 2, // rank: sessionId => qrserver.0.XXXXXXXXXXXXX.0
    0, 0, 0, 4, 'r', 'a', 'n', 'k', 0, 0, 0, 1, 0, 0, 0, 9, 's', 'e', 's', 's', 'i', 'o', 'n', 'I', 'd' });
    answer.putInt(sessionId.asUtf8String().getByteLength());
    answer.put(sessionId.asUtf8String().getBytes());
    answer.put(new byte[] { // caches: features => true
    0, 0, 0, 6, 'c', 'a', 'c', 'h', 'e', 's', 0, 0, 0, 1, 0, 0, 0, 5, 'q', 'u', 'e', 'r', 'y', 0, 0, 0, 4, 't', 'r', 'u', 'e', // flags
    0, 0, 0, 2 });
    byte[] expected = new byte[answer.position()];
    answer.flip();
    answer.get(expected);
    assertPacket(false, result, expected);
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) SessionId(com.yahoo.search.query.SessionId) ByteBuffer(java.nio.ByteBuffer) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 35 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class FastHitTestCase method requireThatIgnoreRowBitsCanBeSet.

@Test
public void requireThatIgnoreRowBitsCanBeSet() {
    FastHit hit = new FastHit();
    hit.setIgnoreRowBits(true);
    assertTrue(hit.shouldIgnoreRowBits());
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Test(org.junit.Test)

Aggregations

FastHit (com.yahoo.prelude.fastsearch.FastHit)51 Result (com.yahoo.search.Result)21 Query (com.yahoo.search.Query)20 Test (org.junit.Test)20 Hit (com.yahoo.search.result.Hit)19 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)9 Relevance (com.yahoo.search.result.Relevance)8 Searcher (com.yahoo.search.Searcher)7 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)6 Execution (com.yahoo.search.searchchain.Execution)5 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)5 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)5 JSONString (com.yahoo.prelude.hitfield.JSONString)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Utf8String (com.yahoo.text.Utf8String)4 HashMap (java.util.HashMap)4 ByteWriter (com.yahoo.io.ByteWriter)3 DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)3 Coverage (com.yahoo.search.result.Coverage)3 HitGroup (com.yahoo.search.result.HitGroup)3