Search in sources :

Example 91 with Result

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

the class GroupingExecutorTestCase method testIllegalQuery.

@Test
public void testIllegalQuery() {
    Execution exc = newExecution(new GroupingExecutor());
    Query query = new Query();
    NotItem notItem = new NotItem();
    notItem.addNegativeItem(new WordItem("negative"));
    query.getModel().getQueryTree().setRoot(notItem);
    Result result = exc.search(query);
    com.yahoo.search.result.ErrorMessage message = result.hits().getError();
    assertNotNull("Got error", message);
    assertEquals("Illegal query", message.getMessage());
    assertEquals("Can not search for only negative items", message.getDetailedMessage());
    assertEquals(3, message.getCode());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) NotItem(com.yahoo.prelude.query.NotItem) Query(com.yahoo.search.Query) WordItem(com.yahoo.prelude.query.WordItem) ErrorMessage(com.yahoo.search.result.ErrorMessage) 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) Test(org.junit.Test)

Example 92 with Result

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

the class GroupingExecutorTestCase method requireThatEmptyRequestsPass.

@Test
public void requireThatEmptyRequestsPass() {
    Query query = newQuery();
    GroupingRequest.newInstance(query).setRootOperation(new AllOperation());
    Result res = newExecution(new GroupingExecutor()).search(query);
    assertNotNull(res);
    assertEquals(0, res.hits().size());
}
Also used : Query(com.yahoo.search.Query) AllOperation(com.yahoo.search.grouping.request.AllOperation) 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) Test(org.junit.Test)

Example 93 with Result

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

the class GroupingExecutorTestCase method requireThatHitsAreFilled.

@Test
public void requireThatHitsAreFilled() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
    Grouping grp0 = new Grouping(0);
    grp0.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar"))));
    Grouping grp1 = new Grouping(0);
    grp1.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp0), null), new GroupingListHit(Arrays.asList(grp1), null))), new FillRequestThrower());
    Result res = exec.search(query);
    // Fill with summary specified in grouping
    try {
        exec.fill(res);
        fail();
    } catch (FillRequestException e) {
        assertEquals("bar", e.summaryClass);
    }
    // Fill again, with another summary
    try {
        exec.fill(res, "otherSummary");
        fail();
    } catch (FillRequestException e) {
        assertEquals("otherSummary", e.summaryClass);
    }
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) 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) Execution(com.yahoo.search.searchchain.Execution) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 94 with Result

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

the class GroupingExecutorTestCase method requireThatErrorsAreHandled.

@Test
public void requireThatErrorsAreHandled() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
    Grouping grp0 = new Grouping(0);
    grp0.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar"))));
    Grouping grp1 = new Grouping(0);
    grp1.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
    ErrorProvider err = new ErrorProvider(1);
    Execution exec = newExecution(new GroupingExecutor(), err, new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp0), null), new GroupingListHit(Arrays.asList(grp1), null))));
    Result res = exec.search(query);
    assertTrue(res.hits().getError() != null);
    assertEquals(Error.TIMEOUT.code, res.hits().getError().getCode());
    assertFalse(err.continuedOnFail);
    err = new ErrorProvider(0);
    exec = newExecution(new GroupingExecutor(), err, new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp0), null), new GroupingListHit(Arrays.asList(grp1), null))));
    res = exec.search(query);
    assertTrue(res.hits().getError() != null);
    assertEquals(Error.TIMEOUT.code, res.hits().getError().getCode());
    assertFalse(err.continuedOnFail);
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) 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) Execution(com.yahoo.search.searchchain.Execution) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 95 with Result

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

the class GroupingExecutorTestCase method requireThatGroupRelevanceCanBeSynthesized.

@Test
public void requireThatGroupRelevanceCanBeSynthesized() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) order(count()) each(output(count())))"));
    Grouping grp = new Grouping(0);
    grp.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new CountAggregationResult(1)).addOrderBy(new AggregationRefNode(0), true)).addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("bar")).addAggregationResult(new CountAggregationResult(2)).addOrderBy(new AggregationRefNode(0), true)));
    Result res = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp), null), new GroupingListHit(Arrays.asList(grp), null)))).search(query);
    GroupList groupList = (GroupList) req.getResultGroup(res).get(0);
    assertEquals(1.0, groupList.get(0).getRelevance().getScore(), 1E-6);
    assertEquals(0.5, groupList.get(1).getRelevance().getScore(), 1E-6);
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) Grouping(com.yahoo.searchlib.aggregation.Grouping) AggregationRefNode(com.yahoo.searchlib.expression.AggregationRefNode) 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) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) GroupList(com.yahoo.search.grouping.result.GroupList) CountAggregationResult(com.yahoo.searchlib.aggregation.CountAggregationResult) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

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