Search in sources :

Example 16 with Execution

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();
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) StupidSingleThreadedHttpServer(com.yahoo.search.StupidSingleThreadedHttpServer) Connection(com.yahoo.search.federation.http.Connection) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 17 with Execution

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

Example 18 with Execution

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);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) GroupList(com.yahoo.search.grouping.result.GroupList) 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) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 19 with Execution

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)));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) List(java.util.List) IndexModel(com.yahoo.prelude.IndexModel) LinkedHashMap(java.util.LinkedHashMap) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 20 with Execution

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;
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) JuniperSearcher(com.yahoo.prelude.searcher.JuniperSearcher) Result(com.yahoo.search.Result)

Aggregations

Execution (com.yahoo.search.searchchain.Execution)232 Query (com.yahoo.search.Query)184 Result (com.yahoo.search.Result)127 Test (org.junit.Test)123 Searcher (com.yahoo.search.Searcher)88 Chain (com.yahoo.component.chain.Chain)59 IndexFacts (com.yahoo.prelude.IndexFacts)34 Hit (com.yahoo.search.result.Hit)25 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 AndItem (com.yahoo.prelude.query.AndItem)18 WordItem (com.yahoo.prelude.query.WordItem)17 ComponentId (com.yahoo.component.ComponentId)13 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FastHit (com.yahoo.prelude.fastsearch.FastHit)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)13 ArrayList (java.util.ArrayList)12 CompositeItem (com.yahoo.prelude.query.CompositeItem)11