use of com.yahoo.prelude.searcher.FillSearcher 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.FillSearcher 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.FillSearcher 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()));
}
use of com.yahoo.prelude.searcher.FillSearcher in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testMultipleBackendsWithErrorMerging.
@Test
public void testMultipleBackendsWithErrorMerging() {
DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
Query q = new Query("/search?query=hannibal&search=a,b");
Result r1 = new Result(q, ErrorMessage.createNoBackendsInService(null));
Result r2 = new Result(q, ErrorMessage.createRequestTooLarge(null));
r1.setTotalHitCount(0);
chain1.addResultSet(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
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(2, cr.getHitCount());
assertEquals(1, cr.getConcreteHitCount());
com.yahoo.search.result.ErrorHit errorHit = cr.hits().getErrorHit();
Iterator errorIterator = errorHit.errorIterator();
List<String> errorList = Arrays.asList("Source 'a': No backends in service. Try later", "Source 'b': 2: Request too large");
String a = errorIterator.next().toString();
assertTrue(a, errorList.contains(a));
String b = errorIterator.next().toString();
assertTrue(a, errorList.contains(b));
assertFalse(errorIterator.hasNext());
assertEquals(102, ((int) cr.hits().get(1).getRelevance().getScore()));
assertEquals(com.yahoo.container.protect.Error.NO_BACKENDS_IN_SERVICE.code, cr.hits().getError().getCode());
}
Aggregations