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));
}
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());
}
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"));
}
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());
}
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;
}
Aggregations