Search in sources :

Example 16 with Hit

use of com.yahoo.search.result.Hit 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 17 with Hit

use of com.yahoo.search.result.Hit 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 18 with Hit

use of com.yahoo.search.result.Hit 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 19 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class QueryValidatingSearcherTestCase method testBasic.

public void testBasic() {
    // Setup
    Map<Searcher, Searcher> chained = new HashMap<>();
    Query query = new Query("?query=test");
    Result result = new Result(query);
    result.hits().add(new Hit("ymail://1111111111/AQAAAP7JgwEAj6XjQQAAAO/+ggA=", 950));
    Searcher validator = new QueryValidatingSearcher();
    DocumentSourceSearcher source = new DocumentSourceSearcher();
    chained.put(validator, source);
    source.addResult(query, result);
    // Exercise
    Result returnedResult = doSearch(validator, query, 0, 10, chained);
    // Validate
    assertEquals(1, returnedResult.getHitCount());
    assertNull(returnedResult.hits().getError());
    returnedResult = doSearch(validator, query, 0, 1001, chained);
    assertEquals(0, returnedResult.getConcreteHitCount());
    assertEquals(4, returnedResult.hits().getError().getCode());
    returnedResult = doSearch(validator, query, 1001, 10, chained);
    assertEquals(0, returnedResult.getConcreteHitCount());
    assertEquals(4, returnedResult.hits().getError().getCode());
}
Also used : Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) QueryValidatingSearcher(com.yahoo.prelude.searcher.QueryValidatingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) QueryValidatingSearcher(com.yahoo.prelude.searcher.QueryValidatingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Result(com.yahoo.search.Result)

Example 20 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class BlendingSearcherTestCase method setupFirstAndSecond.

private BlendingSearcherWrapper setupFirstAndSecond() {
    DocumentSourceSearcher first = new DocumentSourceSearcher();
    DocumentSourceSearcher second = new DocumentSourceSearcher();
    Query query = new Query("?query=banana");
    Result r1 = new Result(query);
    r1.setTotalHitCount(1);
    Hit r1h1 = new Hit("http://first/relevancy100", 200);
    r1.hits().add(r1h1);
    first.addResultSet(query, r1);
    Result r2 = new Result(query);
    r2.setTotalHitCount(2);
    Hit r2h1 = new Hit("http://second/relevancy300", 300);
    Hit r2h2 = new Hit("http://second/relevancy100", 100);
    r2.hits().add(r2h1);
    r2.hits().add(r2h2);
    second.addResultSet(query, r2);
    BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
    blender.addChained(new FillSearcher(first), "first");
    blender.addChained(new FillSearcher(second), "second");
    blender.initialize();
    return blender;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) FillSearcher(com.yahoo.prelude.searcher.FillSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result)

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