Search in sources :

Example 1 with DocumentSourceSearcher

use of com.yahoo.prelude.searcher.DocumentSourceSearcher in project vespa by vespa-engine.

the class CachingSearcherTestCase method setUp.

@Before
public void setUp() throws Exception {
    hits = new DocumentSourceSearcher();
    QrSearchersConfig config = new QrSearchersConfig(new QrSearchersConfig.Builder().com(new QrSearchersConfig.Com.Builder().yahoo(new QrSearchersConfig.Com.Yahoo.Builder().prelude(new QrSearchersConfig.Com.Yahoo.Prelude.Builder().searcher(new QrSearchersConfig.Com.Yahoo.Prelude.Searcher.Builder().CachingSearcher(new QrSearchersConfig.Com.Yahoo.Prelude.Searcher.CachingSearcher.Builder().cachesizemegabytes(10).maxentrysizebytes(5 * 1024 * 1024).timetoliveseconds(86400)))))));
    CachingSearcher cache = new CachingSearcher(config, Statistics.nullImplementation);
    searchChain = new Chain<>(cache, hits);
}
Also used : CachingSearcher(com.yahoo.prelude.searcher.CachingSearcher) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Before(org.junit.Before)

Example 2 with DocumentSourceSearcher

use of com.yahoo.prelude.searcher.DocumentSourceSearcher 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;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) FillSearcher(com.yahoo.prelude.searcher.FillSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result)

Example 3 with DocumentSourceSearcher

use of com.yahoo.prelude.searcher.DocumentSourceSearcher 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 4 with DocumentSourceSearcher

use of com.yahoo.prelude.searcher.DocumentSourceSearcher in project vespa by vespa-engine.

the class BlendingSearcherTestCase method testMultipleBackendsWithDuplicateRemoval.

@Test
public void testMultipleBackendsWithDuplicateRemoval() {
    DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
    DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
    Query q = new Query("/search?query=hannibal&search=a,b");
    Result r1 = new Result(q);
    Result r2 = new Result(q);
    r1.setTotalHitCount(1);
    r1.hits().add(new FastHit("http://host1.com/", 101));
    chain1.addResultSet(q, r1);
    r2.hits().add(new FastHit("http://host1.com/", 102));
    r2.setTotalHitCount(1);
    chain2.addResultSet(q, r2);
    BlendingSearcherWrapper blender = new BlendingSearcherWrapper("uri");
    blender.addChained(new FillSearcher(chain1), "a");
    blender.addChained(new FillSearcher(chain2), "b");
    blender.initialize();
    q.setWindow(0, 10);
    Result cr = new Execution(blender, Execution.Context.createContextStub()).search(q);
    assertEquals(1, cr.getHitCount());
    assertEquals(101, ((int) cr.hits().get(0).getRelevance().getScore()));
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) FillSearcher(com.yahoo.prelude.searcher.FillSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 5 with DocumentSourceSearcher

use of com.yahoo.prelude.searcher.DocumentSourceSearcher in project vespa by vespa-engine.

the class BlendingSearcherTestCase method testBlendingWithSortSpec.

@Test
public void testBlendingWithSortSpec() {
    DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
    DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
    Query q = new Query("/search?query=banana+&sorting=%2Bfoobar");
    Result r1 = new Result(q);
    Result r2 = new Result(q);
    r1.setTotalHitCount(3);
    Hit r1h1 = new Hit("http://host1.com/relevancy101", 101);
    r1h1.setField("foobar", "3");
    r1h1.setQuery(q);
    Hit r1h2 = new Hit("http://host2.com/relevancy102", 102);
    r1h2.setField("foobar", "6");
    r1h2.setQuery(q);
    Hit r1h3 = new Hit("http://host3.com/relevancy103", 103);
    r1h3.setField("foobar", "2");
    r1h3.setQuery(q);
    r1.hits().add(r1h1);
    r1.hits().add(r1h2);
    r1.hits().add(r1h3);
    chain1.addResultSet(q, r1);
    r2.setTotalHitCount(3);
    Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
    r2h1.setField("foobar", "5");
    r2h1.setQuery(q);
    Hit r2h2 = new Hit("http://host2.com/relevancy202", 202);
    r2h2.setField("foobar", "1");
    r2h2.setQuery(q);
    Hit r2h3 = new Hit("http://host3.com/relevancy203", 203);
    r2h3.setField("foobar", "4");
    r2h3.setQuery(q);
    r2.hits().add(r2h1);
    r2.hits().add(r2h2);
    r2.hits().add(r2h3);
    chain2.addResultSet(q, r2);
    BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
    blender.addChained(new FillSearcher(chain1), "chainedone");
    blender.addChained(new FillSearcher(chain2), "chainedtwo");
    blender.initialize();
    q.setWindow(0, 10);
    Result br = new Execution(blender, Execution.Context.createContextStub()).search(q);
    assertEquals(202, ((int) br.hits().get(0).getRelevance().getScore()));
    assertEquals(103, ((int) br.hits().get(1).getRelevance().getScore()));
    assertEquals(101, ((int) br.hits().get(2).getRelevance().getScore()));
    assertEquals(203, ((int) br.hits().get(3).getRelevance().getScore()));
    assertEquals(201, ((int) br.hits().get(4).getRelevance().getScore()));
    assertEquals(102, ((int) br.hits().get(5).getRelevance().getScore()));
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) FillSearcher(com.yahoo.prelude.searcher.FillSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)11 FastHit (com.yahoo.prelude.fastsearch.FastHit)10 Query (com.yahoo.search.Query)10 Result (com.yahoo.search.Result)10 Hit (com.yahoo.search.result.Hit)8 Execution (com.yahoo.search.searchchain.Execution)5 Test (org.junit.Test)5 FillSearcher (com.yahoo.prelude.searcher.FillSearcher)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Searcher (com.yahoo.search.Searcher)4 Relevance (com.yahoo.search.result.Relevance)4 HashMap (java.util.HashMap)4 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)1 HitField (com.yahoo.prelude.hitfield.HitField)1 CachingSearcher (com.yahoo.prelude.searcher.CachingSearcher)1 Iterator (java.util.Iterator)1 Before (org.junit.Before)1