use of com.yahoo.search.result.ErrorMessage in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testNonexistingBackendCausesError.
@Test
public void testNonexistingBackendCausesError() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=nonesuch");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
assertEquals(0, result.getConcreteHitCount());
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
assertEquals("Invalid query parameter", e.getMessage());
// assertEquals("No source named 'nonesuch' to search. Valid sources are [first, second]",
// e.getDetailedMessage());
}
use of com.yahoo.search.result.ErrorMessage in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testNonexistingBackendsCausesErrorOnFirst.
@Test
public void testNonexistingBackendsCausesErrorOnFirst() {
// Feel free to change to include all in the detail message...
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=nonesuch,orsuch");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
assertEquals(0, result.getConcreteHitCount());
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
assertEquals("Invalid query parameter", e.getMessage());
// TODO: Do not depend on sources order
assertEquals("4: Invalid query parameter: Could not resolve source ref 'nonesuch'. Could not resolve source ref 'orsuch'. Valid source refs are first, second.", e.toString());
}
use of com.yahoo.search.result.ErrorMessage in project vespa by vespa-engine.
the class JsonRenderer method renderErrors.
private void renderErrors(Set<ErrorMessage> errors) throws IOException {
if (errors.isEmpty())
return;
generator.writeArrayFieldStart(ERRORS);
for (ErrorMessage e : errors) {
String summary = e.getMessage();
String source = e.getSource();
Throwable cause = e.getCause();
String message = e.getDetailedMessage();
generator.writeStartObject();
generator.writeNumberField(ERROR_CODE, e.getCode());
generator.writeStringField(ERROR_SUMMARY, summary);
if (source != null) {
generator.writeStringField(ERROR_SOURCE, source);
}
if (message != null) {
generator.writeStringField(ERROR_MESSAGE, message);
}
if (cause != null && cause.getStackTrace().length > 0) {
StringWriter s = new StringWriter();
PrintWriter p = new PrintWriter(s);
cause.printStackTrace(p);
p.close();
generator.writeStringField(ERROR_STACK_TRACE, s.toString());
}
generator.writeEndObject();
}
generator.writeEndArray();
}
use of com.yahoo.search.result.ErrorMessage 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.ErrorMessage in project vespa by vespa-engine.
the class GroupingExecutor method fill.
@Override
public void fill(Result result, String summaryClass, Execution execution) {
Map<String, Result> summaryMap = new HashMap<>();
for (Iterator<Hit> it = result.hits().unorderedDeepIterator(); it.hasNext(); ) {
Hit hit = it.next();
Object metaData = hit.getSearcherSpecificMetaData(this);
if (metaData != null && metaData instanceof String) {
// Use the summary class specified by grouping, set in HitConverter, for the first fill request
// after grouping. This assumes the first fill request is using the default summary class,
// which may be a fragile assumption. But currently we cannot do better because the difference
// between explicit and implicit summary class in fill is erased by the Execution.
//
// We reset the summary class here such that following fill calls will execute with the
// summary class they specify
summaryClass = (String) metaData;
hit.setSearcherSpecificMetaData(this, null);
}
Result summaryResult = summaryMap.get(summaryClass);
if (summaryResult == null) {
summaryResult = new Result(result.getQuery());
summaryMap.put(summaryClass, summaryResult);
}
summaryResult.hits().add(hit);
}
for (Map.Entry<String, Result> entry : summaryMap.entrySet()) {
Result res = entry.getValue();
execution.fill(res, entry.getKey());
ErrorMessage err = res.hits().getError();
if (err != null) {
result.hits().addError(err);
}
}
Result defaultResult = summaryMap.get(ExpressionConverter.DEFAULT_SUMMARY_NAME);
if (defaultResult != null) {
// "default" to signal the same
for (Hit hit : defaultResult.hits()) {
hit.setFilled(null);
}
}
}
Aggregations