When there's an error on elasticsearch side, in some native script for instance, explicit it in the error message and at least print the name of the root exception visible to the client.

This commit is contained in:
Nicolas Lalevée 2012-06-08 11:30:27 +02:00 committed by Shay Banon
parent 9905eab73a
commit d49d58058c
2 changed files with 11 additions and 5 deletions

View File

@ -61,13 +61,14 @@ public final class ExceptionsHelper {
if (t.getCause() != null) {
StringBuilder sb = new StringBuilder();
while (t != null) {
sb.append(t.getClass().getSimpleName());
if (t.getMessage() != null) {
sb.append(t.getClass().getSimpleName()).append("[");
sb.append("[");
sb.append(t.getMessage());
sb.append("]");
if (!newLines) {
sb.append("; ");
}
}
if (!newLines) {
sb.append("; ");
}
t = t.getCause();
if (t != null) {

View File

@ -95,7 +95,12 @@ public class CustomScoreQueryParser implements QueryParser {
return null;
}
SearchScript searchScript = parseContext.scriptService().search(parseContext.lookup(), scriptLang, script, vars);
SearchScript searchScript;
try {
searchScript = parseContext.scriptService().search(parseContext.lookup(), scriptLang, script, vars);
} catch (Exception e) {
throw new QueryParsingException(parseContext.index(), "[custom_score] the script could not be loaded", e);
}
FunctionScoreQuery functionScoreQuery = new FunctionScoreQuery(query, new ScriptScoreFunction(script, vars, searchScript));
functionScoreQuery.setBoost(boost);
return functionScoreQuery;