use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class FederationSearcherTestCase method twoTracingSources.
private Chain<Searcher> twoTracingSources(boolean strictContracts) {
addChained(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
query.trace(SOURCE1, 1);
return execution.search(query);
}
}, SOURCE1);
addChained(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
query.trace(SOURCE2, 1);
return execution.search(query);
}
}, SOURCE2);
Chain<Searcher> mainChain = new Chain<>("default", new FederationSearcher(new FederationConfig(builder), new StrictContractsConfig(new StrictContractsConfig.Builder().searchchains(strictContracts)), new ComponentRegistry<>()));
return mainChain;
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class TilingTestCase method testTiling2.
/**
* This result contains center section and meta blocks.
* <p>
* Incidentally, this also tests using an old searcher in new search chains.
*/
public void testTiling2() throws IOException {
Chain<Searcher> chain = new Chain<>("tiling", new TiledResultProducer2());
// Query it
Query query = new Query("/tiled?query=foo");
Result result = callSearchAndSetRenderer(chain, query);
assertRendered(IOUtils.readFile(new File("src/test/java/com/yahoo/prelude/templates/test/tilingexample2.xml")), result);
}
use of com.yahoo.component.chain.Chain 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);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class JuniperSearcherTestCase method createSearchChain.
/**
* Creates a search chain which always returns a result with one hit containing information given in this
*
* @param sdName the search definition type of the returned hit
* @param content the content of the "dynteaser" field of the returned hit
*/
private Chain<Searcher> createSearchChain(String sdName, String content) {
JuniperSearcher searcher = new JuniperSearcher(new ComponentId("test"), new QrSearchersConfig(new QrSearchersConfig.Builder()));
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
addResult(new Query("?query=12"), sdName, content, docsource);
addResult(new Query("?query=12&bolding=false"), sdName, content, docsource);
return new Chain<Searcher>(searcher, docsource);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class JSONDebugSearcherTestCase method makeSearchChain.
private Chain<Searcher> makeSearchChain(String content, Searcher dumper) {
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
addResult(new Query(DUMPJSON), content, docsource);
addResult(new Query(NODUMPJSON), content, docsource);
return new Chain<>(dumper, docsource);
}
Aggregations