Search in sources :

Example 11 with Result

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

the class DocumentSourceSearcher method search.

public Result search(com.yahoo.search.Query query, Execution execution) {
    queryCount++;
    Result r;
    r = unFilledResults.get(getQueryKeyClone(query));
    if (r == null) {
        r = defaultFilledResult.clone();
    } else {
        r = r.clone();
    }
    r.setQuery(query);
    r.hits().trim(query.getOffset(), query.getHits());
    return r;
}
Also used : Result(com.yahoo.search.Result)

Example 12 with Result

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

the class JuniperSearcher method fill.

@Override
public void fill(Result result, String summaryClass, Execution execution) {
    Result workResult = result;
    final int worstCase = workResult.getHitCount();
    final List<Hit> hits = new ArrayList<>(worstCase);
    for (final Iterator<Hit> i = workResult.hits().deepIterator(); i.hasNext(); ) {
        final Hit sniffHit = i.next();
        if (!(sniffHit instanceof FastHit))
            continue;
        final FastHit hit = (FastHit) sniffHit;
        if (hit.isFilled(summaryClass))
            continue;
        hits.add(hit);
    }
    execution.fill(workResult, summaryClass);
    highlight(workResult.getQuery().getPresentation().getBolding(), hits.iterator(), summaryClass, execution.context().getIndexFacts().newSession(result.getQuery()));
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) ArrayList(java.util.ArrayList) Result(com.yahoo.search.Result)

Example 13 with Result

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

the class JuniperSearcher method search.

/**
 * Convert Juniper style property highlighting to XML style.
 */
@Override
public Result search(Query query, Execution execution) {
    Result result = execution.search(query);
    highlight(query.getPresentation().getBolding(), result.hits().deepIterator(), null, execution.context().getIndexFacts().newSession(query));
    return result;
}
Also used : Result(com.yahoo.search.Result)

Example 14 with Result

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

the class QueryValidatingSearcher method search.

public Result search(Query query, Execution execution) {
    if (query.getHits() > 1000) {
        Result result = new Result(query);
        ErrorMessage error = ErrorMessage.createInvalidQueryParameter("Too many hits (more than 1000) requested.");
        result.hits().addError(error);
        return result;
    }
    if (query.getOffset() > 1000) {
        Result result = new Result(query);
        ErrorMessage error = ErrorMessage.createInvalidQueryParameter("Offset too high (above 1000).");
        result.hits().addError(error);
        return result;
    }
    return execution.search(query);
}
Also used : ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result)

Example 15 with Result

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

the class ValidatePredicateSearcher method search.

@Override
public Result search(Query query, Execution execution) {
    Optional<ErrorMessage> e = validate(query, execution.context().getIndexFacts().newSession(query));
    if (e.isPresent()) {
        Result r = new Result(query);
        r.hits().addError(e.get());
        return r;
    }
    return execution.search(query);
}
Also used : ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result)

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