Search in sources :

Example 46 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class PartialFillTestCase method testPartitioning.

@Test
public void testPartitioning() {
    FS4 fs4 = new FS4();
    Query a = new Query("/?query=foo");
    Query b = new Query("/?query=bar");
    // equal to a
    Query c = new Query("/?query=foo");
    Result r = new Result(new Query("/?query=ignorethis"));
    for (int i = 0; i < 7; i++) {
        FastHit h = new FastHit();
        h.setQuery(a);
        h.setFillable();
        r.hits().add(h);
    }
    for (int i = 0; i < 5; i++) {
        FastHit h = new FastHit();
        h.setQuery(b);
        h.setFillable();
        r.hits().add(h);
    }
    for (int i = 0; i < 3; i++) {
        FastHit h = new FastHit();
        h.setQuery(c);
        h.setFillable();
        r.hits().add(h);
    }
    for (int i = 0; i < 2; i++) {
        FastHit h = new FastHit();
        // no query assigned
        h.setFillable();
        r.hits().add(h);
    }
    for (int i = 0; i < 5; i++) {
        FastHit h = new FastHit();
        // not fillable
        h.setQuery(a);
        r.hits().add(h);
    }
    for (int i = 0; i < 5; i++) {
        FastHit h = new FastHit();
        // already filled
        h.setQuery(a);
        h.setFilled("default");
        r.hits().add(h);
    }
    doFill(fs4, r, "default");
    assertNull(r.hits().getErrorHit());
    assertEquals(4, fs4.history.size());
    assertEquals(a, fs4.history.get(0).getQuery());
    assertEquals(7, fs4.history.get(0).getHitCount());
    assertEquals(b, fs4.history.get(1).getQuery());
    assertEquals(5, fs4.history.get(1).getHitCount());
    assertEquals(c, fs4.history.get(2).getQuery());
    assertEquals(3, fs4.history.get(2).getHitCount());
    assertEquals(r.getQuery(), fs4.history.get(3).getQuery());
    assertEquals(2, fs4.history.get(3).getHitCount());
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 47 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class DocsumDefinitionTestCase method testDecoding.

@Test
public void testDecoding() {
    String summary_cf = "file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg";
    DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf);
    FastHit hit = new FastHit();
    set.lazyDecode(null, makeDocsum(), hit);
    assertEquals("Arts/Celebrities/Madonna", hit.getField("TOPIC"));
    assertEquals("1", hit.getField("EXTINFOSOURCE").toString());
    assertEquals("10", hit.getField("LANG1").toString());
    assertEquals("352", hit.getField("WORDS").toString());
    assertEquals("index:0/0/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) Test(org.junit.Test)

Example 48 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit 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 49 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit 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)

Example 50 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class QuotingSearcherTestCase method testBasicQuoting.

public void testBasicQuoting() {
    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 & jones");
    r.hits().add(hit);
    docsource.addResultSet(q, r);
    Result check = doSearch(s, q, 0, 10, chained);
    assertEquals("smith &amp; jones", 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)

Aggregations

FastHit (com.yahoo.prelude.fastsearch.FastHit)51 Result (com.yahoo.search.Result)21 Query (com.yahoo.search.Query)20 Test (org.junit.Test)20 Hit (com.yahoo.search.result.Hit)19 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)9 Relevance (com.yahoo.search.result.Relevance)8 Searcher (com.yahoo.search.Searcher)7 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)6 Execution (com.yahoo.search.searchchain.Execution)5 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)5 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)5 JSONString (com.yahoo.prelude.hitfield.JSONString)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Utf8String (com.yahoo.text.Utf8String)4 HashMap (java.util.HashMap)4 ByteWriter (com.yahoo.io.ByteWriter)3 DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)3 Coverage (com.yahoo.search.result.Coverage)3 HitGroup (com.yahoo.search.result.HitGroup)3