use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class JsonRendererTestCase method testGroupingWithBucket.
@Test
public void testGroupingWithBucket() throws InterruptedException, ExecutionException, IOException {
String expected = "{\n" + " \"root\": {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"fields\": {\n" + " \"something()\": 7\n" + " },\n" + " \"limits\": {\n" + " \"from\": \"1.0\",\n" + " \"to\": \"2.0\"\n" + " },\n" + " \"id\": \"group:double_bucket:1.0:2.0\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"id\": \"grouplist:customer\",\n" + " \"label\": \"customer\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"continuation\": {\n" + " \"this\": \"AAAA\"\n" + " },\n" + " \"id\": \"group:root:0\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"fields\": {\n" + " \"totalCount\": 1\n" + " },\n" + " \"id\": \"toplevel\",\n" + " \"relevance\": 1.0\n" + " }\n" + "}\n";
Result r = newEmptyResult();
RootGroup rg = new RootGroup(0, new Continuation() {
@Override
public String toString() {
return "AAAA";
}
});
GroupList gl = new GroupList("customer");
Group g = new Group(new DoubleBucketId(1.0, 2.0), new Relevance(1.0));
g.setField("something()", Integer.valueOf(7));
gl.add(g);
rg.add(gl);
r.hits().add(rg);
r.setTotalHitCount(1L);
String summary = render(r);
assertEqualJson(expected, summary);
}
use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class QuerySnapshotSearcher method search.
public Result search(Query query, Execution execution) {
Query q = query.clone();
Result r = execution.search(query);
Hit h = new Hit("meta:querysnapshot", new Relevance(Double.POSITIVE_INFINITY));
h.setMeta(true);
h.setField("query", q);
r.hits().add(h);
return r;
}
use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class ResultBuilder method endElement.
@Override
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
switch(location.peekFirst()) {
case HITGROUP:
if ("group".equals(qName)) {
hitGroups.removeFirst();
location.removeFirst();
}
break;
case HIT:
if (fieldLevel > 0) {
endElementInHitField(qName);
} else if ("hit".equals(qName)) {
// assert(hitKeys.size() == hitValues.size());
// We try to get either uri or documentID and use that as id
Object docId = extractDocumentID();
Hit newHit = new Hit(docId.toString());
if (hitRelevance != null)
newHit.setRelevance(new Relevance(DoubleParser.parse(hitRelevance)));
if (hitSource != null)
newHit.setSource(hitSource);
if (hitType != null) {
for (String type : hitType.split(" ")) {
newHit.types().add(type);
}
}
for (Map.Entry<String, Object> field : hitFields.entrySet()) {
newHit.setField(field.getKey(), field.getValue());
}
hitGroups.peekFirst().add(newHit);
location.removeFirst();
}
break;
case ERRORDETAILS:
if (fieldLevel == 1 && ERROR.equals(qName)) {
ErrorMessage error = new ErrorMessage(Integer.valueOf(currentErrorCode), currentError, fieldContent.toString());
hitGroups.peekFirst().addError(error);
currentError = null;
currentErrorCode = null;
fieldContent = null;
tagStack = null;
fieldLevel = 0;
} else if (fieldLevel > 0) {
endElementInField(qName, ERROR);
} else if ("errordetails".equals(qName)) {
location.removeFirst();
}
break;
case ROOT:
if (ERROR.equals(qName)) {
ErrorMessage error = new ErrorMessage(Integer.valueOf(currentErrorCode), fieldContent.toString());
hitGroups.peekFirst().addError(error);
currentErrorCode = null;
fieldContent = null;
}
break;
default:
break;
}
++offset;
}
use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class VdsStreamingSearcher method buildSummaryHit.
private FastHit buildSummaryHit(Query query, SearchResult.Hit hit) {
FastHit fastHit = new FastHit();
fastHit.setQuery(query);
fastHit.setSource(getName());
fastHit.setId(hit.getDocId());
fastHit.setRelevance(new Relevance(hit.getRank()));
fastHit.setFillable();
return fastHit;
}
use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.
the class JuniperSearcherTestCase method addResult.
private void addResult(Query query, String sdName, String content, DocumentSourceSearcher docsource) {
Result r = new Result(query);
FastHit hit = new FastHit();
hit.setId("http://abc.html");
hit.setRelevance(new Relevance(1));
hit.setField(Hit.SDDOCNAME_FIELD, sdName);
hit.setField("dynteaser", content);
r.hits().add(hit);
docsource.addResult(query, r);
}
Aggregations