use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testNoCollapsingIfNotAskedTo.
@Test
public void testNoCollapsingIfNotAskedTo() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher();
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
Query q = new Query("?query=test_collapse");
Result r = new Result(q);
r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 1));
r.hits().add(createHit("http://acme.org/d.html", 8, 1));
r.hits().add(createHit("http://acme.org/e.html", 8, 2));
r.hits().add(createHit("http://acme.org/f.html", 7, 2));
r.hits().add(createHit("http://acme.org/g.html", 7, 3));
r.hits().add(createHit("http://acme.org/h.html", 6, 3));
r.setTotalHitCount(8);
docsource.addResult(q, r);
// Test that no collapsing occured
q = new Query("?query=test_collapse");
r = doSearch(collapse, q, 0, 10, chained);
assertEquals(8, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testCollapsingDispersedCollection.
/**
* Tests collapsing of "messy" data
*/
@Test
public void testCollapsingDispersedCollection() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(1, 2.0, "amid");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
Query q = new Query("?query=test_collapse&collapse=true&collapsefield=amid");
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
r.hits().add(createHit("http://acme.org/a.html", 10, 1));
r.hits().add(createHit("http://acme.org/b.html", 10, 1));
r.hits().add(createHit("http://acme.org/c.html", 10, 0));
r.hits().add(createHit("http://acme.org/d.html", 10, 0));
r.hits().add(createHit("http://acme.org/e.html", 10, 0));
r.hits().add(createHit("http://acme.org/f.html", 10, 0));
r.hits().add(createHit("http://acme.org/g.html", 10, 0));
r.hits().add(createHit("http://acme.org/h.html", 10, 0));
r.hits().add(createHit("http://acme.org/i.html", 10, 0));
r.hits().add(createHit("http://acme.org/j.html", 10, 1));
r.setTotalHitCount(10);
docsource.addResult(q, r);
// Test collapsing
q = new Query("?query=test_collapse&collapse=true&collapsefield=amid");
r = doSearch(collapse, q, 0, 3, chained);
assertEquals(2, r.getHitCount());
assertHit("http://acme.org/a.html", 10, 1, r.hits().get(0));
assertHit("http://acme.org/c.html", 10, 0, r.hits().get(1));
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testCollapsingLargeCollection.
/**
* Tests that collapsing many hits from one site works, and without
* an excessive number of backend requests
*/
@Test
public void testCollapsingLargeCollection() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(4, 2.0, "amid");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
Query q = new Query("?query=test_collapse&collapsesize=1&collapsefield=amid");
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 0));
r.hits().add(createHit("http://acme.org/d.html", 8, 0));
r.hits().add(createHit("http://acme.org/e.html", 8, 0));
r.hits().add(createHit("http://acme.org/f.html", 7, 0));
r.hits().add(createHit("http://acme.org/g.html", 7, 0));
r.hits().add(createHit("http://acme.org/h.html", 6, 0));
r.hits().add(createHit("http://acme.org/i.html", 5, 1));
r.hits().add(createHit("http://acme.org/j.html", 4, 2));
r.setTotalHitCount(10);
docsource.addResult(q, r);
// Test collapsing
q = new Query("?query=test_collapse&collapsesize=1&collapsefield=amid");
r = doSearch(collapse, q, 0, 2, chained);
assertEquals(2, r.getHitCount());
assertEquals(2, docsource.getQueryCount());
assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/i.html", 5, 1, r.hits().get(1));
// Next results
docsource.resetQueryCount();
r = doSearch(collapse, q, 2, 2, chained);
assertEquals(1, r.getHitCount());
assertEquals(2, docsource.getQueryCount());
assertHit("http://acme.org/j.html", 4, 2, r.hits().get(0));
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class MultipleResultsTestCase method setUp.
@Before
public void setUp() {
docSource = new DocumentSourceSearcher();
searcher = new MultipleResultsSearcher();
chain = new Chain<>("multipleresultschain", searcher, docSource);
}
Aggregations