use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testFieldCollapsingTwoPhaseSelectSummary.
// This test depends on DocumentSourceSearcher filling the hits
// with whatever data it got, ignoring actual summary arguments
// in the fill call, then saying the hits are filled for the
// ignored argument. Rewrite to contain different summaries if
// DocumentSourceSearcher gets extended.
@Test
public void testFieldCollapsingTwoPhaseSelectSummary() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
// Caveat: Collapse is set to false, because that's what the
// collapser asks for
Query q = new Query("?query=test_collapse&collapsefield=amid&summary=placeholder");
// 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, 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 basic collapsing on mid
q = new Query("?query=test_collapse&collapsefield=amid&summary=placeholder");
r = doSearch(collapse, q, 0, 10, chained);
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
assertTrue(r.isFilled("placeholder"));
assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
docsource.resetQueryCount();
// Test basic collapsing on mid
q = new Query("?collapse.summary=short&query=test_collapse&collapsefield=amid&summary=placeholder");
r = doSearch(collapse, q, 0, 10, chained);
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
assertFalse(r.isFilled("placeholder"));
assertTrue(r.isFilled("short"));
assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testFieldCollapsingTwoPhase.
@Test
public void testFieldCollapsingTwoPhase() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
// Caveat: Collapse is set to false, because that's what the
// collapser asks for
Query q = new Query("?query=test_collapse&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, 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 basic collapsing on mid
q = new Query("?query=test_collapse&collapsefield=amid");
r = doSearch(collapse, q, 0, 10, chained);
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testQueryTransformAndCollapsing.
@Test
public void testQueryTransformAndCollapsing() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
Searcher messUp = new QueryMessupSearcher();
chained.put(collapse, messUp);
chained.put(messUp, docsource);
// Caveat: Collapse is set to false, because that's what the
// collapser asks for
Query q = new Query("?query=test_collapse+b&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, 1));
r.setTotalHitCount(8);
docsource.addResult(q, r);
// Test basic collapsing on mid
q = new Query("?query=test_collapse&collapsefield=amid");
r = doSearch(collapse, q, 0, 2, chained);
assertEquals(2, docsource.getQueryCount());
assertEquals(2, r.getHitCount());
assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/h.html", 6, 1, r.hits().get(1));
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testFieldCollapsing.
@Test
public void testFieldCollapsing() {
Map<Searcher, Searcher> chained = new HashMap<>();
// Set up
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
// Caveat: Collapse is set to false, because that's what the
// collapser asks for
Query q = new Query("?query=test_collapse&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, 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 basic collapsing on mid
q = new Query("?query=test_collapse&collapsefield=amid");
r = doSearch(collapse, q, 0, 10, chained);
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.
the class FieldCollapsingSearcherTestCase method testFieldCollapsingWithGrouping.
@Test
public void testFieldCollapsingWithGrouping() {
// Set up
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
Chain<Searcher> chain = new Chain<>(collapse, new AddAggregationStyleGroupingResultSearcher(), docsource);
// Caveat: Collapse is set to false, because that's what the
// collapser asks for
Query q = new Query("?query=test_collapse&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, 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 basic collapsing on mid
Query query = new Query("?query=test_collapse&collapsefield=amid");
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
// Assert that the regular hits are collapsed
assertEquals(4 + 1, result.getHitCount());
assertEquals(1, docsource.getQueryCount());
assertHit("http://acme.org/a.html", 10, 0, result.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, result.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, result.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, result.hits().get(3));
// Assert that the aggregation group hierarchy is left intact
HitGroup root = getFirstGroupIn(result.hits());
assertNotNull(root);
// The id ends by a global counter currently
assertEquals("group:root:", root.getId().stringValue().substring(0, 11));
assertEquals(1, root.size());
HitGroup groupList = (GroupList) root.get("grouplist:g1");
assertNotNull(groupList);
assertEquals(1, groupList.size());
HitGroup group = (HitGroup) groupList.get("group:long:37");
assertNotNull(group);
}
Aggregations