Search in sources :

Example 1 with FS4Hit

use of com.yahoo.searchlib.aggregation.FS4Hit in project vespa by vespa-engine.

the class HitConverterTestCase method requireThatHitHasContext.

@Test
public void requireThatHitHasContext() {
    HitConverter converter = new HitConverter(new MySearcher(), new Query());
    try {
        converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3));
        fail();
    } catch (NullPointerException e) {
    }
}
Also used : FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 2 with FS4Hit

use of com.yahoo.searchlib.aggregation.FS4Hit 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 3 with FS4Hit

use of com.yahoo.searchlib.aggregation.FS4Hit 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 4 with FS4Hit

use of com.yahoo.searchlib.aggregation.FS4Hit 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 5 with FS4Hit

use of com.yahoo.searchlib.aggregation.FS4Hit 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

FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)6 FastHit (com.yahoo.prelude.fastsearch.FastHit)5 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)5 Query (com.yahoo.search.Query)5 Hit (com.yahoo.search.result.Hit)5 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)5 Test (org.junit.Test)5 QueryPacketData (com.yahoo.fs4.QueryPacketData)2 URI (com.yahoo.net.URI)1 Searcher (com.yahoo.search.Searcher)1