Search in sources :

Example 6 with FastHit

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

the class DefaultTemplateSet method renderFieldContent.

protected void renderFieldContent(Context context, Hit hit, String name, XMLWriter writer) throws IOException {
    boolean dumpedRaw = false;
    if (hit instanceof FastHit && ((FastHit) hit).fieldIsNotDecoded(name)) {
        writer.closeStartTag();
        if ((writer.getWriter() instanceof ByteWriter) && context.isUtf8Output()) {
            dumpedRaw = dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, name);
        }
        if (dumpedRaw) {
            // let the xml writer note that this tag had content
            writer.content("", false);
        }
    }
    if (!dumpedRaw) {
        String xmlval = hit.getFieldXML(name);
        if (xmlval == null) {
            xmlval = "(null)";
        }
        writer.escapedContent(xmlval, false);
    }
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) ByteWriter(com.yahoo.io.ByteWriter) Utf8String(com.yahoo.text.Utf8String)

Example 7 with FastHit

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

the class HitConverterTestCase method requireThatSummaryClassIsSet.

@Test
public void requireThatSummaryClassIsSet() {
    Searcher searcher = new MySearcher();
    HitConverter converter = new HitConverter(searcher, new Query());
    Hit hit = converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3).setContext(new Hit("hit:ctx")));
    assertNotNull(hit);
    assertTrue(hit instanceof FastHit);
    assertEquals("69", hit.getSearcherSpecificMetaData(searcher));
}
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) Searcher(com.yahoo.search.Searcher) Test(org.junit.Test)

Example 8 with FastHit

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

the class HitConverterTestCase method requireThatContextDataIsCopied.

@Test
public void requireThatContextDataIsCopied() {
    Hit ctxHit = new Hit("hit:ctx");
    ctxHit.setSource("69");
    ctxHit.setSourceNumber(69);
    Query ctxQuery = new Query();
    ctxHit.setQuery(ctxQuery);
    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);
    assertEquals(1, ((FastHit) hit).getPartId());
    assertEquals(createGlobalId(2), ((FastHit) hit).getGlobalId());
    assertSame(ctxQuery, hit.getQuery());
    assertEquals(ctxHit.getSource(), hit.getSource());
    assertEquals(ctxHit.getSourceNumber(), hit.getSourceNumber());
}
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) Test(org.junit.Test)

Example 9 with FastHit

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

the class HitConverterTestCase method requireThatVdsHitCanBeConverted.

@Test
public void requireThatVdsHitCanBeConverted() {
    HitConverter converter = new HitConverter(new MySearcher(), new Query());
    GroupingListHit context = new GroupingListHit(null, new DocsumDefinitionSet(sixtynine()));
    VdsHit lowHit = new VdsHit("doc:scheme:", new byte[] { 0x55, 0x55, 0x55, 0x55 }, 1);
    lowHit.setContext(context);
    Hit hit = converter.toSearchHit("69", lowHit);
    assertNotNull(hit);
    assertTrue(hit instanceof FastHit);
    assertEquals(new Relevance(1), hit.getRelevance());
    assertTrue(hit.isFilled("69"));
}
Also used : Relevance(com.yahoo.search.result.Relevance) 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) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) Test(org.junit.Test)

Example 10 with FastHit

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

the class CachingSearcherTestCase method readyResult.

public void readyResult(String q) {
    Query query = new Query(q);
    Result r = new Result(query);
    for (int i = 0; i < 10; ++i) {
        FastHit h = new FastHit("http://127.0.0.1/" + i, 1.0 - ((double) i) / 10.0);
        r.hits().add(h);
    }
    hits.addResultSet(query, r);
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

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