Search in sources :

Example 91 with Searcher

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));
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 92 with Searcher

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;
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result)

Example 93 with Searcher

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());
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) QueryProfile(com.yahoo.search.query.profile.QueryProfile) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 94 with Searcher

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);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 95 with Searcher

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());
}
Also used : Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8