Search in sources :

Example 96 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class GroupingExecutorTestCase method requireThatDefaultSummaryNameFillsHitsWithNull.

@Test
public void requireThatDefaultSummaryNameFillsHitsWithNull() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary()))) as(foo))"));
    Grouping pass0 = new Grouping(0);
    pass0.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME))));
    Grouping pass1 = new Grouping(0);
    pass1.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME).addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(pass0), null), new GroupingListHit(Arrays.asList(pass1), null))));
    Result res = exec.search(query);
    exec.fill(res);
    Hit hit = ((HitList) ((Group) ((GroupList) req.getResultGroup(res).get(0)).get(0)).get(0)).get(0);
    assertTrue(hit instanceof FastHit);
    assertTrue(hit.isFilled(null));
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) HitList(com.yahoo.search.grouping.result.HitList) Grouping(com.yahoo.searchlib.aggregation.Grouping) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) Result(com.yahoo.search.Result) HitsAggregationResult(com.yahoo.searchlib.aggregation.HitsAggregationResult) CountAggregationResult(com.yahoo.searchlib.aggregation.CountAggregationResult) MinAggregationResult(com.yahoo.searchlib.aggregation.MinAggregationResult) MaxAggregationResult(com.yahoo.searchlib.aggregation.MaxAggregationResult) HitsAggregationResult(com.yahoo.searchlib.aggregation.HitsAggregationResult) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) FastHit(com.yahoo.prelude.fastsearch.FastHit) GroupList(com.yahoo.search.grouping.result.GroupList) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 97 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class ResultTestCase method testHitOrdering.

public void testHitOrdering() {
    Result result = new Result(new Query("dummy"));
    result.hits().add(new Hit("test:hit1", 80));
    result.hits().add(new Hit("test:hit2", 90));
    result.hits().add(new Hit("test:hit3", 70));
    Iterator<?> hits = result.hits().deepIterator();
    assertEquals(new Hit("test:hit2", 90), hits.next());
    assertEquals(new Hit("test:hit1", 80), hits.next());
    assertEquals(new Hit("test:hit3", 70), hits.next());
}
Also used : Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

Example 98 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class ResultTestCase method testHitTrimming.

public void testHitTrimming() {
    Result result = new Result(new Query("dummy"));
    // case 1: keep some hits in the middle
    resultInit(result);
    result.hits().trim(3, 3);
    assertEquals(3, result.getHitCount());
    Iterator<Hit> hits = result.hits().deepIterator();
    assertEquals(new Hit("test:hit3", 70), hits.next());
    assertEquals(new Hit("test:hit8", 55), hits.next());
    assertEquals(new Hit("test:hit5", 50), hits.next());
    assertEquals(false, hits.hasNext());
    // case 2: keep some hits at the end
    result = new Result(new Query("dummy"));
    resultInit(result);
    result.hits().trim(5, 4);
    hits = result.hits().deepIterator();
    assertEquals(new Hit("test:hit5", 50), hits.next());
    assertEquals(new Hit("test:hit4", 40), hits.next());
    assertEquals(new Hit("test:hit6", 20), hits.next());
    assertEquals(new Hit("test:hit7", 20), hits.next());
    assertEquals(false, hits.hasNext());
    // case 3: keep some hits at the beginning
    result = new Result(new Query("dummy"));
    resultInit(result);
    result.hits().trim(0, 4);
    hits = result.hits().deepIterator();
    assertEquals(new Hit("test:hit2", 90), hits.next());
    assertEquals(new Hit("test:hit1", 80), hits.next());
    assertEquals(new Hit("test:hit9", 75), hits.next());
    assertEquals(new Hit("test:hit3", 70), hits.next());
    assertEquals(false, hits.hasNext());
    // case 4: keep no hits
    result = new Result(new Query("dummy"));
    resultInit(result);
    result.hits().trim(10, 4);
    hits = result.hits().deepIterator();
    assertEquals(false, hits.hasNext());
}
Also used : Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

Example 99 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class SecondSearcher method search.

public Result search(com.yahoo.search.Query query, Execution execution) {
    Result result = execution.search(query);
    result.hits().add(new Hit("searcher:2", 996));
    return result;
}
Also used : Hit(com.yahoo.search.result.Hit) Result(com.yahoo.search.Result)

Example 100 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class ClusteredConnectionTestCase method testClusteringWithPing.

public void testClusteringWithPing() {
    Connection connection0 = new Connection("0");
    Connection connection1 = new Connection("1");
    Connection connection2 = new Connection("2");
    List<Connection> connections = new ArrayList<>();
    connections.add(connection0);
    connections.add(connection1);
    connections.add(connection2);
    MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
    Result r;
    // Note that we cannot make any successful queries here or we have to wait 10 seconds for
    // the traffic monitor to agree that these nodes are really not responding
    connection2.setInService(false);
    connection1.setInService(false);
    connection0.setInService(false);
    forcePing(myBackend);
    r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
    assertEquals("No backends in service. Try later", r.hits().getError().getMessage());
    connection2.setInService(true);
    connection1.setInService(true);
    connection0.setInService(true);
    forcePing(myBackend);
    r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
    assertNull(r.hits().getError());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) ArrayList(java.util.ArrayList) ComponentId(com.yahoo.component.ComponentId) Result(com.yahoo.search.Result)

Aggregations

Result (com.yahoo.search.Result)398 Test (org.junit.Test)231 Query (com.yahoo.search.Query)229 Execution (com.yahoo.search.searchchain.Execution)127 Searcher (com.yahoo.search.Searcher)94 Hit (com.yahoo.search.result.Hit)72 Chain (com.yahoo.component.chain.Chain)48 FastHit (com.yahoo.prelude.fastsearch.FastHit)36 HitGroup (com.yahoo.search.result.HitGroup)29 JSONString (com.yahoo.prelude.hitfield.JSONString)26 HashMap (java.util.HashMap)21 FeedContext (com.yahoo.feedapi.FeedContext)19 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)19 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)19 ClusterList (com.yahoo.vespaclient.ClusterList)19 ErrorMessage (com.yahoo.search.result.ErrorMessage)17 Choice (com.yahoo.search.pagetemplates.model.Choice)16 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)15 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)15 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)14