use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class HttpPostTestCase method testPostingSearcher.
@Test
public void testPostingSearcher() throws Exception {
StupidSingleThreadedHttpServer server = new StupidSingleThreadedHttpServer();
server.start();
TestPostSearcher searcher = new TestPostSearcher(new ComponentId("foo:1"), Arrays.asList(new Connection("localhost", server.getServerPort())), "/");
Query q = new Query("");
q.setTimeout(10000000L);
Execution e = new Execution(searcher, Execution.Context.createContextStub());
searcher.search(q, e);
assertThat(server.getRequest(), containsString("My POST body"));
server.stop();
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class CachingSearcherTestCase method testNoCacheWrite.
@Test
public final void testNoCacheWrite() {
readyResult(QUERY_A_NOCACHEWRITE_TRUE);
Execution e = new Execution(searchChain, Execution.Context.createContextStub());
Result r = e.search(new Query(QUERY_A_NOCACHEWRITE_TRUE));
assertEquals(10, r.hits().getConcreteSize());
Query query = new Query(QUERY_A_NOCACHEWRITE_TRUE);
Result expected = new Result(query);
hits.addResultSet(query, expected);
e = new Execution(searchChain, Execution.Context.createContextStub());
r = e.search(new Query(QUERY_A_NOCACHEWRITE_TRUE));
assertEquals(0, r.hits().getConcreteSize());
assertEquals(2, hits.getQueryCount());
}
use of com.yahoo.search.searchchain.Execution 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.search.searchchain.Execution in project vespa by vespa-engine.
the class JuniperSearcherTestCase method createExecution.
private Execution createExecution(Chain<Searcher> chain) {
Map<String, List<String>> clusters = new LinkedHashMap<>();
Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
searchDefs.put("one", createSearchDefinitionOne());
searchDefs.put("two", createSearchDefinitionTwo());
SearchDefinition union = new SearchDefinition("union");
IndexModel indexModel = new IndexModel(clusters, searchDefs, union);
return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class JuniperSearcherTestCase method createResult.
private Result createResult(String sdName, String content, boolean bolding) {
Chain<Searcher> chain = createSearchChain(sdName, content);
Query query = new Query("?query=12");
if (!bolding)
query = new Query("?query=12&bolding=false");
Execution execution = createExecution(chain);
Result result = execution.search(query);
execution.fill(result);
return result;
}
Aggregations