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);
}
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;
}
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("&smith &jo& nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
}
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()));
}
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()));
}
Aggregations