use of com.yahoo.net.URI in project vespa by vespa-engine.
the class FastHit method getIndexUri.
/**
* The uri of the index location of this hit ("index:[source]/[partid]/[id]").
* This is the uri if no other uri is assigned
*
* @return uri to the index.
*/
public URI getIndexUri() {
if (indexUri != null)
return indexUri;
String rowString = "-";
if (useRowInIndexUri)
rowString = String.valueOf(getRow());
indexUri = new URI("index:" + getSourceNumber() + "/" + getColumn() + "/" + rowString + "/" + asHexString(getGlobalId()));
return indexUri;
}
use of com.yahoo.net.URI in project vespa by vespa-engine.
the class Result method trace.
/**
* Adds a context message to this query containing the entire content of this result,
* if tracelevel is 5 or more.
*
* @param name the name of the searcher instance returning this result
*/
public void trace(String name) {
if (hits().getQuery().getTraceLevel() < 5) {
return;
}
StringBuilder hitBuffer = new StringBuilder(name);
hitBuffer.append(" returns:\n");
int counter = 0;
for (Iterator<Hit> i = hits.unorderedIterator(); i.hasNext(); ) {
Hit hit = i.next();
if (hit.isMeta())
continue;
hitBuffer.append(" #: ");
hitBuffer.append(counter);
traceExtraHitProperties(hitBuffer, hit);
hitBuffer.append(", relevancy: ");
hitBuffer.append(hit.getRelevance());
hitBuffer.append(", addno: ");
hitBuffer.append(hit.getAddNumber());
hitBuffer.append(", source: ");
hitBuffer.append(hit.getSource());
hitBuffer.append(", uri: ");
URI uri = hit.getId();
if (uri != null) {
hitBuffer.append(uri.getHost());
} else {
hitBuffer.append("(no uri)");
}
hitBuffer.append("\n");
counter++;
}
if (counter == 0) {
hitBuffer.append("(no hits)\n");
}
hits.getQuery().trace(hitBuffer.toString(), false, 5);
}
use of com.yahoo.net.URI in project vespa by vespa-engine.
the class ResultBuilderTestCase method testSimpleResult.
public void testSimpleResult() {
boolean gotErrorDetails = false;
ResultBuilder r = new ResultBuilder();
Result res = r.parse("file:src/test/java/com/yahoo/prelude/searcher/test/testhit.xml", new Query("?query=a"));
assertEquals(3, res.getConcreteHitCount());
assertEquals(4, res.getHitCount());
ErrorHit e = (ErrorHit) res.hits().get(0);
// is no way of nuking an existing error if the details exist.
for (Iterator<?> i = e.errorIterator(); i.hasNext(); ) {
ErrorMessage err = (ErrorMessage) i.next();
assertEquals(5, err.getCode());
String details = err.getDetailedMessage();
if (details != null) {
gotErrorDetails = true;
assertEquals("An error as ordered", details.trim());
}
}
assertTrue("Error details are missing", gotErrorDetails);
assertEquals(new URI("http://def"), res.hits().get(1).getId());
assertEquals("test/stuff\\tsome/other", res.hits().get(2).getField("category"));
assertEquals("<field>habla</field>" + "<hi>blbl</hi><br /><>&fdlkkgj</field>;lk<a b=\"1\" c=\"2\" />" + "<x><y><z /></y></x>", res.hits().get(3).getField("annoying").toString());
}
use of com.yahoo.net.URI in project vespa by vespa-engine.
the class ResultBuilderTestCase method testWeirdDocumentID.
public void testWeirdDocumentID() {
ResultBuilder r = new ResultBuilder();
Result res = r.parse("file:src/test/java/com/yahoo/search/federation/vespa/test/idhits.xml", new Query("?query=a"));
assertNull(res.hits().getError());
assertEquals(3, res.hits().size());
assertEquals(new URI("nalle"), res.hits().get(0).getId());
assertEquals(new URI("tralle"), res.hits().get(1).getId());
assertEquals(new URI("kalle"), res.hits().get(2).getId());
}
use of com.yahoo.net.URI in project vespa by vespa-engine.
the class HitGroup method get.
/**
* Returns the hit with the given id, or null if there is no hit with this id
* in this group or any subgroup.
* This method is o(min(number of nested hits in this result,depth)).
*
* @param id the id of the hit to return from this or any nested group
* @param depth the max depth to recurse into nested groups: -1: Recurse infinitely deep, 0: Only look at hits in
* the list of this group, 1: Look at hits in this group, and the hits of any immediate nested HitGroups,
* etc.
* @return The hit, or null if not found.
*/
public Hit get(URI id, int depth) {
updateHits();
for (Iterator<Hit> i = unorderedIterator(); i.hasNext(); ) {
Hit hit = i.next();
URI hitUri = hit.getId();
if (hitUri != null && hitUri.equals(id)) {
return hit;
}
if (hit instanceof HitGroup && depth != 0) {
Hit found = ((HitGroup) hit).get(id, depth - 1);
if (found != null)
return found;
}
}
return null;
}
Aggregations