Search in sources :

Example 36 with Execution

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

the class NonPhrasingSearcherTestCase method testMultipleWordNonPhrasing.

@Test
public void testMultipleWordNonPhrasing() {
    searcher = new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
    Query query = new Query("?query=void+tudor+vidor+kanoo");
    new Execution(searcher, Execution.Context.createContextStub()).search(query);
    CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
    assertEquals(2, item.getItemCount());
    assertEquals("void", ((WordItem) item.getItem(0)).getWord());
    assertEquals("kanoo", ((WordItem) item.getItem(1)).getWord());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) NonPhrasingSearcher(com.yahoo.prelude.querytransform.NonPhrasingSearcher) Test(org.junit.Test)

Example 37 with Execution

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

the class VespaIntegrationTestCase method testIt.

// TODO: Setup the answering vespa searcher from this test....
public void testIt() {
    if (System.currentTimeMillis() > 0)
        return;
    Chain<Searcher> chain = new Chain<>(new VespaSearcher("test", "example.yahoo.com", 19010, ""));
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=test"));
    assertEquals(23, result.hits().size());
}
Also used : Chain(com.yahoo.component.chain.Chain) VespaSearcher(com.yahoo.search.federation.vespa.VespaSearcher) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) VespaSearcher(com.yahoo.search.federation.vespa.VespaSearcher) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result)

Example 38 with Execution

use of com.yahoo.search.searchchain.Execution 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 39 with Execution

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

the class GroupingExecutorTestCase method requireThatHitsAreFilledWithCorrectSummary.

@Test
public void requireThatHitsAreFilledWithCorrectSummary() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar))) as(bar) " + "                    each(output(summary(baz))) as(baz)))"));
    Grouping pass0A = new Grouping(0);
    pass0A.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar"))));
    Grouping pass0B = new Grouping(1);
    pass0B.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "baz"))));
    GlobalId gid1 = new GlobalId((new DocumentId("doc:test:1")).getGlobalId());
    GlobalId gid2 = new GlobalId((new DocumentId("doc:test:2")).getGlobalId());
    Grouping pass1A = new Grouping(0);
    pass1A.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(1, gid1, 3)))));
    Grouping pass1B = new Grouping(1);
    pass1B.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "baz").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid2, 6)))));
    SummaryMapper sm = new SummaryMapper();
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(pass0A, pass0B), null), new GroupingListHit(Arrays.asList(pass1A, pass1B), null))), sm);
    exec.fill(exec.search(query), "default");
    assertEquals(2, sm.hitsBySummary.size());
    List<Hit> lst = sm.hitsBySummary.get("bar");
    assertNotNull(lst);
    assertEquals(1, lst.size());
    Hit hit = lst.get(0);
    assertTrue(hit instanceof FastHit);
    assertEquals(1, ((FastHit) hit).getPartId());
    assertEquals(gid1, ((FastHit) hit).getGlobalId());
    assertNotNull(lst = sm.hitsBySummary.get("baz"));
    assertNotNull(lst);
    assertEquals(1, lst.size());
    hit = lst.get(0);
    assertTrue(hit instanceof FastHit);
    assertEquals(4, ((FastHit) hit).getPartId());
    assertEquals(gid2, ((FastHit) hit).getGlobalId());
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) DocumentId(com.yahoo.document.DocumentId) Grouping(com.yahoo.searchlib.aggregation.Grouping) GlobalId(com.yahoo.document.GlobalId) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) 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) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 40 with Execution

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

the class GroupingExecutorTestCase method requireThatHitsAreAttachedToCorrectQuery.

@Test
public void requireThatHitsAreAttachedToCorrectQuery() {
    Query queryA = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(queryA);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
    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 HitsAggregationResult(1, "bar"))));
    GroupingListHit pass0 = new GroupingListHit(Arrays.asList(grp), null);
    GlobalId gid = new GlobalId((new DocumentId("doc:test:1")).getGlobalId());
    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 HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid, 6)))));
    GroupingListHit pass1 = new GroupingListHit(Arrays.asList(grp), null);
    Query queryB = newQuery();
    /**
     * required by {@link GroupingListHit#getSearchQuery()}
     */
    pass1.setQuery(queryB);
    QueryMapper qm = new QueryMapper();
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(pass0, pass1)), qm);
    exec.fill(exec.search(queryA));
    assertEquals(1, qm.hitsByQuery.size());
    assertTrue(qm.hitsByQuery.containsKey(queryB));
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) DocumentId(com.yahoo.document.DocumentId) Grouping(com.yahoo.searchlib.aggregation.Grouping) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) GlobalId(com.yahoo.document.GlobalId) 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)

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