use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class VespaBackEndSearcher method extractDocumentInfo.
private void extractDocumentInfo(FastHit hit, DocumentInfo document) {
hit.setSourceNumber(sourceNumber);
hit.setSource(getName());
Number rank = document.getMetric();
hit.setRelevance(new Relevance(rank.doubleValue()));
hit.setDistributionKey(document.getDistributionKey());
hit.setGlobalId(document.getGlobalId());
hit.setPartId(document.getPartId(), rowBits);
}
use of com.yahoo.search.result.Relevance 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.Relevance in project vespa by vespa-engine.
the class GroupTestCase method requireThatListsAreAccessibleByLabel.
@Test
public void requireThatListsAreAccessibleByLabel() {
Group grp = new Group(new LongId(69L), new Relevance(1));
grp.add(new Hit("hit"));
grp.add(new HitList("hitList"));
grp.add(new GroupList("groupList"));
assertNotNull(grp.getGroupList("groupList"));
assertNull(grp.getGroupList("unknownGroupList"));
assertNull(grp.getGroupList("hitList"));
assertNotNull(grp.getHitList("hitList"));
assertNull(grp.getHitList("unknownHitList"));
assertNull(grp.getHitList("groupList"));
}
use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class QuotingSearcherTestCase method testBasicQuotingWithNoisyStrings.
public void testBasicQuotingWithNoisyStrings() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/" + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
Result r = new Result(q);
Hit hit = new FastHit();
hit.setId("http://abc.html");
hit.setRelevance(new Relevance(1));
hit.setField("title", "&smith &jo& nes");
r.hits().add(hit);
docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("&smith &jo& nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
}
use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class JsonRendererTestCase method testGrouping.
@Test
public void testGrouping() throws InterruptedException, ExecutionException, IOException {
String expected = "{\n" + " \"root\": {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"fields\": {\n" + " \"count()\": 7\n" + " },\n" + " \"value\": \"Jones\",\n" + " \"id\": \"group:string:Jones\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"continuation\": {\n" + " \"next\": \"CCCC\",\n" + " \"prev\": \"BBBB\"\n" + " },\n" + " \"id\": \"grouplist:customer\",\n" + " \"label\": \"customer\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"continuation\": {\n" + " \"this\": \"AAAA\"\n" + " },\n" + " \"id\": \"group:root:0\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"fields\": {\n" + " \"totalCount\": 1\n" + " },\n" + " \"id\": \"toplevel\",\n" + " \"relevance\": 1.0\n" + " }\n" + "}\n";
Result r = newEmptyResult();
RootGroup rg = new RootGroup(0, new Continuation() {
@Override
public String toString() {
return "AAAA";
}
});
GroupList gl = new GroupList("customer");
gl.continuations().put("prev", new Continuation() {
@Override
public String toString() {
return "BBBB";
}
});
gl.continuations().put("next", new Continuation() {
@Override
public String toString() {
return "CCCC";
}
});
Group g = new Group(new StringId("Jones"), new Relevance(1.0));
g.setField("count()", Integer.valueOf(7));
gl.add(g);
rg.add(gl);
r.hits().add(rg);
r.setTotalHitCount(1L);
String summary = render(r);
assertEqualJson(expected, summary);
}
Aggregations