Search in sources :

Example 1 with Relevance

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);
}
Also used : Relevance(com.yahoo.search.result.Relevance)

Example 2 with Relevance

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"));
}
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 3 with Relevance

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"));
}
Also used : Relevance(com.yahoo.search.result.Relevance) Hit(com.yahoo.search.result.Hit) Test(org.junit.Test)

Example 4 with Relevance

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("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
    assertTrue(check.hits().get(0).fields().containsKey("title"));
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) QuotingSearcher(com.yahoo.prelude.searcher.QuotingSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result)

Example 5 with Relevance

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);
}
Also used : Relevance(com.yahoo.search.result.Relevance) Group(com.yahoo.search.grouping.result.Group) RootGroup(com.yahoo.search.grouping.result.RootGroup) HitGroup(com.yahoo.search.result.HitGroup) Continuation(com.yahoo.search.grouping.Continuation) GroupList(com.yahoo.search.grouping.result.GroupList) StringId(com.yahoo.search.grouping.result.StringId) JSONString(com.yahoo.prelude.hitfield.JSONString) RootGroup(com.yahoo.search.grouping.result.RootGroup) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Relevance (com.yahoo.search.result.Relevance)16 Hit (com.yahoo.search.result.Hit)10 Result (com.yahoo.search.Result)9 FastHit (com.yahoo.prelude.fastsearch.FastHit)8 Query (com.yahoo.search.Query)6 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Searcher (com.yahoo.search.Searcher)4 Group (com.yahoo.search.grouping.result.Group)4 RootGroup (com.yahoo.search.grouping.result.RootGroup)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 JSONString (com.yahoo.prelude.hitfield.JSONString)3 GroupList (com.yahoo.search.grouping.result.GroupList)3 StringId (com.yahoo.search.grouping.result.StringId)3 Continuation (com.yahoo.search.grouping.Continuation)2 HitList (com.yahoo.search.grouping.result.HitList)2 HitGroup (com.yahoo.search.result.HitGroup)2 DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)1 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)1