Search in sources :

Example 81 with Hit

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

the class CacheTestCase method getSomeResult.

private Result getSomeResult(Query q, String id) {
    Result r = new Result(q);
    r.hits().add(new Hit(id, 10));
    return r;
}
Also used : Hit(com.yahoo.search.result.Hit) Result(com.yahoo.search.Result)

Example 82 with Hit

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

the class DocumentSourceSearcher method addDefaultResults.

private void addDefaultResults() {
    Query q = new Query("?query=default");
    Result r = new Result(q);
    // These four used to assign collapseId 1,2,3,4 - re-add that if needed
    r.hits().add(new Hit("http://default-1.html", 0));
    r.hits().add(new Hit("http://default-2.html", 0));
    r.hits().add(new Hit("http://default-3.html", 0));
    r.hits().add(new Hit("http://default-4.html", 0));
    defaultFilledResult = r;
    addResult(q, r);
}
Also used : Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

Example 83 with Hit

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

the class DocumentSourceSearcher method fillHits.

private void fillHits(Result filledHits, Result hitsToFill, String summaryClass) {
    Set<String> fieldsToFill = summaryClasses.get(summaryClass);
    if (fieldsToFill == null) {
        fieldsToFill = summaryClasses.get(DEFAULT_SUMMARY_CLASS);
    }
    for (Hit hitToFill : hitsToFill.hits()) {
        Hit filledHit = getMatchingFilledHit(hitToFill.getId(), filledHits);
        if (filledHit != null) {
            if (fieldsToFill != null) {
                copyFieldValuesThatExist(filledHit, hitToFill, fieldsToFill);
            } else {
                // TODO: remove this block and update fieldsToFill above to throw an exception if no appropriate summary class is found
                for (Map.Entry<String, Object> propertyEntry : filledHit.fields().entrySet()) {
                    hitToFill.setField(propertyEntry.getKey(), propertyEntry.getValue());
                }
            }
            hitToFill.setFilled(summaryClass == null ? DEFAULT_SUMMARY_CLASS : summaryClass);
        }
    }
    hitsToFill.analyzeHits();
}
Also used : Hit(com.yahoo.search.result.Hit) Map(java.util.Map) HashMap(java.util.HashMap)

Example 84 with Hit

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

the class PeakQpsSearcher method search.

@Override
public Result search(Query query, Execution execution) {
    Result r;
    long when = query.getStartTime() / 1000L;
    Hit meta = null;
    directory.update(when);
    if (useMetaHit) {
        if (query.properties().getBoolean(propertyName, false)) {
            List<QueryRatePerSecond> l = merge(directory.fetch());
            Tuple2<Integer, Double> maxAndMean = maxAndMean(l);
            meta = new QpsHit(maxAndMean.first, maxAndMean.second);
        }
    }
    r = execution.search(query);
    if (meta != null) {
        r.hits().add(meta);
    }
    return r;
}
Also used : Hit(com.yahoo.search.result.Hit) Result(com.yahoo.search.Result)

Example 85 with Hit

use of com.yahoo.search.result.Hit 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

Hit (com.yahoo.search.result.Hit)127 Result (com.yahoo.search.Result)72 Query (com.yahoo.search.Query)52 FastHit (com.yahoo.prelude.fastsearch.FastHit)42 Test (org.junit.Test)41 Execution (com.yahoo.search.searchchain.Execution)25 HitGroup (com.yahoo.search.result.HitGroup)21 Searcher (com.yahoo.search.Searcher)17 JSONString (com.yahoo.prelude.hitfield.JSONString)13 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)12 ErrorHit (com.yahoo.search.result.ErrorHit)10 Relevance (com.yahoo.search.result.Relevance)10 HashMap (java.util.HashMap)9 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)8 Group (com.yahoo.search.grouping.result.Group)8 ComponentId (com.yahoo.component.ComponentId)7 Chain (com.yahoo.component.chain.Chain)7 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)6 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)6 GroupList (com.yahoo.search.grouping.result.GroupList)5