Search in sources :

Example 26 with HitGroup

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

the class FillingTestCase method testFillingAPIConsistencyThreePhase.

public void testFillingAPIConsistencyThreePhase() {
    HitGroup group = new HitGroup();
    group.add(createNonFilled("hit:1"));
    group.add(createNonFilled("hit:2"));
    assertFalse(group.isFilled("summary"));
    assertFalse(group.isFilled("otherSummary"));
    fillHitsIn(group, "otherSummary");
    group.analyze();
    assertFalse(group.isFilled("summary"));
    assertTrue(group.isFilled("otherSummary"));
    fillHitsIn(group, "summary");
    assertTrue(group.isFilled("otherSummary"));
    group.analyze();
    // consistent again
    assertTrue(group.isFilled("summary"));
    assertTrue(group.isFilled("otherSummary"));
}
Also used : HitGroup(com.yahoo.search.result.HitGroup)

Example 27 with HitGroup

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

the class FillingTestCase method testFillingAPIConsistencyTwoPhase.

public void testFillingAPIConsistencyTwoPhase() {
    HitGroup group = new HitGroup();
    group.add(createNonFilled("hit:1"));
    group.add(createNonFilled("hit:2"));
    assertFalse(group.isFilled("summary"));
    fillHitsIn(group, "summary");
    group.analyze();
    // consistent again
    assertTrue(group.isFilled("summary"));
}
Also used : HitGroup(com.yahoo.search.result.HitGroup)

Example 28 with HitGroup

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

the class ResultBenchmark method createResult.

private final Result createResult() {
    // 8 sets, 8 gets
    Result result = new Result(new Query("?query=test&hits=10&presentation.bolding=true&model.type=all"));
    addHits(5, "firstTopLevel", result.hits());
    result.hits().add(addHits(10, "group1hit", new HitGroup()));
    addHits(5, "secondTopLevel", result.hits());
    result.hits().add(addHits(10, "group2hit", new HitGroup()));
    result.hits().add(addHits(10, "group3hit", new HitGroup()));
    return result;
}
Also used : Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup)

Example 29 with HitGroup

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

the class FederationSearcher method mergeResult.

private void mergeResult(Query query, Target target, Result mergedResults, Result result) {
    target.modifyTargetResult(result);
    ComponentId searchChainId = target.getId();
    Chain<Searcher> searchChain = target.getChain();
    mergedResults.mergeWith(result);
    HitGroup group = result.hits();
    group.setId("source:" + searchChainId.getName());
    group.setSearcherSpecificMetaData(this, searchChain);
    // Set hit groups as non-meta as a default
    group.setMeta(false);
    // Set hit group as auxiliary so that it doesn't contribute to count
    group.setAuxiliary(true);
    group.setSource(searchChainId.getName());
    group.setQuery(result.getQuery());
    for (Iterator<Hit> it = group.unorderedDeepIterator(); it.hasNext(); ) {
        Hit hit = it.next();
        hit.setSearcherSpecificMetaData(this, searchChain);
        hit.setSource(searchChainId.stringValue());
        // See HTTPBackendSearcher, where this hit is created
        if (hit.isMeta() && hit.types().contains("logging")) {
            // Augment this hit with count fields
            hit.setField(LOG_COUNT_PREFIX + "deep", result.getDeepHitCount());
            hit.setField(LOG_COUNT_PREFIX + "total", result.getTotalHitCount());
            int offset = result.getQuery().getOffset();
            hit.setField(LOG_COUNT_PREFIX + "first", offset + 1);
            hit.setField(LOG_COUNT_PREFIX + "last", result.getConcreteHitCount() + offset);
        }
    }
    if (query.getTraceLevel() >= 4)
        query.trace("Got " + group.getConcreteSize() + " hits from " + group.getId(), false, 4);
    mergedResults.hits().add(group);
}
Also used : Hit(com.yahoo.search.result.Hit) Searcher(com.yahoo.search.Searcher) ForkingSearcher(com.yahoo.search.searchchain.ForkingSearcher) ComponentId(com.yahoo.component.ComponentId) HitGroup(com.yahoo.search.result.HitGroup)

Example 30 with HitGroup

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

the class GetSearcherTestCase method testQueryPassThrough.

/* Test that a query without any ids is passed through to the next chain */
@Test
public void testQueryPassThrough() throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    HitGroup hits = new HitGroup("mock");
    hits.add(new Hit("blernsball"));
    Chain<Searcher> searchChain = new Chain<>(searcher, new MockBackend(hits));
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?flarn=blern"));
    assertEquals(0, factory.messages.size());
    assertEquals(1, result.hits().size());
    assertNotNull(result.hits().get("blernsball"));
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Aggregations

HitGroup (com.yahoo.search.result.HitGroup)48 Test (org.junit.Test)28 Result (com.yahoo.search.Result)27 Query (com.yahoo.search.Query)24 Hit (com.yahoo.search.result.Hit)21 Execution (com.yahoo.search.searchchain.Execution)11 Searcher (com.yahoo.search.Searcher)8 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)8 Choice (com.yahoo.search.pagetemplates.model.Choice)8 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)7 DefaultErrorHit (com.yahoo.search.result.DefaultErrorHit)6 Chain (com.yahoo.component.chain.Chain)5 ErrorHit (com.yahoo.search.result.ErrorHit)4 ComponentId (com.yahoo.component.ComponentId)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 FederationSearcher (com.yahoo.search.federation.FederationSearcher)3 Resolution (com.yahoo.search.pagetemplates.engine.Resolution)3 Resolver (com.yahoo.search.pagetemplates.engine.Resolver)3 Coverage (com.yahoo.search.result.Coverage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3