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;
}
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);
}
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();
}
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;
}
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"));
}
Aggregations