Search in sources :

Example 6 with ErrorMessage

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());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 7 with ErrorMessage

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());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 8 with ErrorMessage

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();
}
Also used : StringWriter(java.io.StringWriter) ErrorMessage(com.yahoo.search.result.ErrorMessage) PrintWriter(java.io.PrintWriter)

Example 9 with ErrorMessage

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);
        }
    }
}
Also used : ErrorHit(com.yahoo.search.result.ErrorHit) Metric(com.yahoo.jdisc.Metric) ErrorMessage(com.yahoo.search.result.ErrorMessage)

Example 10 with ErrorMessage

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);
        }
    }
}
Also used : GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) Hit(com.yahoo.search.result.Hit) HashMap(java.util.HashMap) ErrorMessage(com.yahoo.search.result.ErrorMessage) HashMap(java.util.HashMap) Map(java.util.Map) Result(com.yahoo.search.Result)

Aggregations

ErrorMessage (com.yahoo.search.result.ErrorMessage)23 Result (com.yahoo.search.Result)16 Query (com.yahoo.search.Query)10 Test (org.junit.Test)9 ErrorHit (com.yahoo.search.result.ErrorHit)4 IndexFacts (com.yahoo.prelude.IndexFacts)3 Execution (com.yahoo.search.searchchain.Execution)3 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)2 Hit (com.yahoo.search.result.Hit)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Metric (com.yahoo.jdisc.Metric)1 URI (com.yahoo.net.URI)1 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)1 JSONString (com.yahoo.prelude.hitfield.JSONString)1 XMLString (com.yahoo.prelude.hitfield.XMLString)1 FederationTarget (com.yahoo.search.federation.selection.FederationTarget)1