use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class FederationSearcherTestCase method testTopLevelHitGroupFieldPropagation.
@Test
public void testTopLevelHitGroupFieldPropagation() {
addChained(new MockSearcher(), "mySource1");
addChained(new AnotherMockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
Query q = new Query("?query=test");
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
assertNull(result.hits().getError());
assertEquals("source:mySource1", result.hits().get(0).getId().stringValue());
assertEquals("source:mySource2", result.hits().get(1).getId().stringValue());
assertEquals(AnotherMockSearcher.IS_THIS_PROPAGATED, result.hits().get(1).getField(AnotherMockSearcher.PROPAGATION_KEY));
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class FederationSearcherTestCase method searchWithPropertyPropagation.
private Result searchWithPropertyPropagation(PropagateSourceProperties.Enum propagateSourceProperties) {
addChained(new MockSearcher(), "mySource1");
addChained(new MockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher(propagateSourceProperties));
Query q = new Query(QueryTestCase.httpEncode("?query=test&source.mySource1.presentation.summary=nalle"));
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
assertNull(result.hits().getError());
return result;
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class FederationSearcherTestCase method testQueryProfileNestedReferencing.
@Test
public void testQueryProfileNestedReferencing() {
addChained(new MockSearcher(), "mySource1");
addChained(new MockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
QueryProfile defaultProfile = new QueryProfile("default");
defaultProfile.set("source.mySource1.hits", "%{hits}", null);
defaultProfile.freeze();
Query q = new Query(QueryTestCase.httpEncode("?query=test"), defaultProfile.compile(null));
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
assertNull(result.hits().getError());
assertEquals("source:mySource1", result.hits().get(0).getId().stringValue());
assertEquals("source:mySource2", result.hits().get(1).getId().stringValue());
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class FederationSearcherTestCase method testTraceOneSourceWithCloning.
@Test
public void testTraceOneSourceWithCloning() {
Chain<Searcher> mainChain = twoTracingSources(false);
Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1&sources=source1"));
Execution execution = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null));
Result result = execution.search(q);
assertNull(result.hits().getError());
TwoSourceChecker lookForTraces = new TwoSourceChecker();
execution.trace().accept(lookForTraces);
assertTrue(lookForTraces.traceFromSource1);
assertFalse(lookForTraces.traceFromSource2);
}
use of com.yahoo.search.Searcher 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());
}
Aggregations