Search in sources :

Example 11 with Relevance

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

the class UniqueGroupingSearcherTestCase method makeHitGroup.

private static Group makeHitGroup(String name) {
    Group ein = new Group(new StringId(name), new Relevance(0));
    HitList hits = new HitList(UniqueGroupingSearcher.LABEL_HITS);
    hits.add(new Hit(name));
    ein.add(hits);
    return ein;
}
Also used : Relevance(com.yahoo.search.result.Relevance) RootGroup(com.yahoo.search.grouping.result.RootGroup) Group(com.yahoo.search.grouping.result.Group) Hit(com.yahoo.search.result.Hit) StringId(com.yahoo.search.grouping.result.StringId) HitList(com.yahoo.search.grouping.result.HitList)

Example 12 with Relevance

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

the class UniqueGroupingSearcherTestCase method makeSortingHitGroup.

private static Group makeSortingHitGroup(String name) {
    Hit hit = new Hit(name);
    HitList hits = new HitList(UniqueGroupingSearcher.LABEL_HITS);
    hits.add(hit);
    Group dedupGroup = new Group(new StringId(name), new Relevance(0));
    dedupGroup.add(hits);
    GroupList dedupedHits = new GroupList(UniqueGroupingSearcher.LABEL_GROUPS);
    dedupedHits.add(dedupGroup);
    Group ein = new Group(new StringId(name), new Relevance(0));
    ein.add(dedupedHits);
    return ein;
}
Also used : Relevance(com.yahoo.search.result.Relevance) RootGroup(com.yahoo.search.grouping.result.RootGroup) Group(com.yahoo.search.grouping.result.Group) Hit(com.yahoo.search.result.Hit) StringId(com.yahoo.search.grouping.result.StringId) GroupList(com.yahoo.search.grouping.result.GroupList) HitList(com.yahoo.search.grouping.result.HitList)

Example 13 with Relevance

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

the class JSONDebugSearcherTestCase method addResult.

private void addResult(Query q, String content, DocumentSourceSearcher docsource) {
    Result r = new Result(q);
    FastHit hit = new FastHit();
    hit.setId("http://abc.html");
    hit.setRelevance(new Relevance(1));
    hit.setField("jsonfield", new JSONString(content));
    r.hits().add(hit);
    docsource.addResult(q, r);
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit) JSONString(com.yahoo.prelude.hitfield.JSONString) Result(com.yahoo.search.Result)

Example 14 with Relevance

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

the class QuotingSearcherTestCase method testFieldQuotingWithNoisyStrings.

public void testFieldQuotingWithNoisyStrings() {
    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", new HitField("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) HitField(com.yahoo.prelude.hitfield.HitField) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result)

Example 15 with Relevance

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

the class QuotingSearcherTestCase method testNoQuotingWithOtherTypes.

public void testNoQuotingWithOtherTypes() {
    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", new Integer(42));
    r.hits().add(hit);
    docsource.addResultSet(q, r);
    Result check = doSearch(s, q, 0, 10, chained);
    // should not quote non-string properties
    assertEquals(new Integer(42), check.hits().get(0).getField("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)

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