Search in sources :

Example 11 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class FieldCollapsingSearcherTestCase method createHit.

private FastHit createHit(String uri, int relevancy, int mid) {
    FastHit hit = new FastHit(uri, relevancy);
    hit.setField("amid", String.valueOf(mid));
    return hit;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 12 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit 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 13 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit 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 14 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class MultipleResultsTestCase method createHit.

private FastHit createHit(String uri, int relevancy, String docName) {
    FastHit hit = new FastHit(uri, relevancy);
    hit.setField(Hit.SDDOCNAME_FIELD, docName);
    return hit;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 15 with FastHit

use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.

the class QuotingSearcherTestCase method testBasicQuotingWithNoisyStrings.

public void testBasicQuotingWithNoisyStrings() {
    Map<Searcher, Searcher> chained = new HashMap<>();
    Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/" + "searcher/test/testquoting.cfg");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(s, docsource);
    Query q = new Query("?query=a");
    Result r = new Result(q);
    Hit hit = new FastHit();
    hit.setId("http://abc.html");
    hit.setRelevance(new Relevance(1));
    hit.setField("title", "&smith &jo& nes");
    r.hits().add(hit);
    docsource.addResultSet(q, r);
    Result check = doSearch(s, q, 0, 10, chained);
    assertEquals("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
    assertTrue(check.hits().get(0).fields().containsKey("title"));
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) QuotingSearcher(com.yahoo.prelude.searcher.QuotingSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result)

Aggregations

FastHit (com.yahoo.prelude.fastsearch.FastHit)51 Result (com.yahoo.search.Result)21 Query (com.yahoo.search.Query)20 Test (org.junit.Test)20 Hit (com.yahoo.search.result.Hit)19 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)9 Relevance (com.yahoo.search.result.Relevance)8 Searcher (com.yahoo.search.Searcher)7 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)6 Execution (com.yahoo.search.searchchain.Execution)5 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)5 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)5 JSONString (com.yahoo.prelude.hitfield.JSONString)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Utf8String (com.yahoo.text.Utf8String)4 HashMap (java.util.HashMap)4 ByteWriter (com.yahoo.io.ByteWriter)3 DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)3 Coverage (com.yahoo.search.result.Coverage)3 HitGroup (com.yahoo.search.result.HitGroup)3