use of com.yahoo.search.result.ErrorHit 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.search.result.ErrorHit in project vespa by vespa-engine.
the class PosSearcherTestCase method testInvalidInput.
/**
* Tests input parameters that should report errors.
*/
@Test
public void testInvalidInput() {
PosSearcher searcher = new PosSearcher();
Result result;
Query q = new Query();
q.properties().set("pos.ll", "NE74.14;E14.48");
result = doSearch(searcher, q, 0, 10);
assertEquals("Error in pos parameters: Unable to parse lat/long string 'NE74.14;E14.48': already set direction once, cannot add direction: E", ((ErrorHit) result.hits().get(0)).errors().iterator().next().getDetailedMessage());
q = new Query();
q.properties().set("pos.ll", "NE74.14;E14.48");
q.properties().set("pos.xy", "82400, 72800");
result = doSearch(searcher, q, 0, 10);
assertEquals("Error in pos parameters: Cannot handle both lat/long and xy coords at the same time", ((ErrorHit) result.hits().get(0)).errors().iterator().next().getDetailedMessage());
}
use of com.yahoo.search.result.ErrorHit in project vespa by vespa-engine.
the class JsonRenderer method renderHitGroupHead.
private void renderHitGroupHead(HitGroup hitGroup) throws IOException {
generator.writeStartObject();
renderHitContents(hitGroup);
if (getRecursionLevel() == 1)
renderCoverage();
ErrorHit errorHit = hitGroup.getErrorHit();
if (errorHit != null)
renderErrors(errorHit.errors());
// the framework will invoke begin methods as needed from here
}
use of com.yahoo.search.result.ErrorHit in project vespa by vespa-engine.
the class StatisticsSearcher method incrementStatePageOnlyErrors.
/**
* Creates error metric for StateHandler only. These metrics are only exposed on /state/v1/metrics page
* and not forwarded to the log file.
*
* @param result The result to check for errors
*/
private void incrementStatePageOnlyErrors(Result result) {
if (result == null)
return;
ErrorHit error = result.hits().getErrorHit();
if (error == null)
return;
for (ErrorMessage m : error.errors()) {
int code = m.getCode();
Metric.Context c = getDimensions(m.getSource());
if (code == TIMEOUT.code) {
metric.add("error.timeout", 1, c);
} else if (code == NO_BACKENDS_IN_SERVICE.code) {
metric.add("error.backends_oos", 1, c);
} else if (code == ERROR_IN_PLUGIN.code) {
metric.add("error.plugin_failure", 1, c);
} else if (code == BACKEND_COMMUNICATION_ERROR.code) {
metric.add("error.backend_communication_error", 1, c);
} else if (code == EMPTY_DOCUMENTS.code) {
metric.add("error.empty_document_summaries", 1, c);
} else if (code == ILLEGAL_QUERY.code) {
metric.add("error.illegal_query", 1, c);
} else if (code == INVALID_QUERY_PARAMETER.code) {
metric.add("error.invalid_query_parameter", 1, c);
} else if (code == INTERNAL_SERVER_ERROR.code) {
metric.add("error.internal_server_error", 1, c);
} else if (code == SERVER_IS_MISCONFIGURED.code) {
metric.add("error.misconfigured_server", 1, c);
} else if (code == INVALID_QUERY_TRANSFORMATION.code) {
metric.add("error.invalid_query_transformation", 1, c);
} else if (code == RESULT_HAS_ERRORS.code) {
metric.add("error.result_with_errors", 1, c);
} else if (code == UNSPECIFIED.code) {
metric.add("error.unspecified", 1, c);
}
}
}
use of com.yahoo.search.result.ErrorHit in project vespa by vespa-engine.
the class DocumentXMLTemplate method error.
@Override
public void error(Context context, Writer writer) throws IOException {
writer.write("<errors>\n");
// If the error contains no error hits, use a single error with the main
// code and description. Otherwise, use the error hits explicitly
ErrorHit errorHit = ((Result) context.get("result")).hits().getErrorHit();
if (errorHit == null || errorHit.errors().isEmpty()) {
ErrorMessage message = ((Result) context.get("result")).hits().getError();
writeGenericErrorMessage(writer, message);
} else {
for (ErrorMessage message : errorHit.errors()) {
writeGenericErrorMessage(writer, message);
}
}
writer.write("</errors>\n");
}
Aggregations