SOLR-6622 - using all field values in UIMAUpdateRequestProcessor

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1723982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tommaso Teofili 2016-01-11 08:12:37 +00:00
parent 5db6df0ca2
commit 8a7a142efb
1 changed files with 20 additions and 16 deletions

View File

@ -102,19 +102,13 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
logField = uniqueKeyField.getName(); logField = uniqueKeyField.getName();
} }
} }
String optionalFieldInfo = logField == null ? "." String optionalFieldInfo = logField == null ? "." : ". " + logField + "=" + cmd.getSolrInputDocument().
: new StringBuilder(". ") getField(logField).getValue() + ", ";
.append(logField)
.append("=")
.append(
(String) cmd.getSolrInputDocument().getField(logField)
.getValue()).append(", ").toString();
int len; int len;
String debugString; String debugString;
if (text != null && text.length() > 0) { if (text != null && text.length() > 0) {
len = Math.min(text.length(), 100); len = Math.min(text.length(), 100);
debugString = new StringBuilder(" text=\"") debugString = " text=\"" + text.substring(0, len) + "...\"";
.append(text.substring(0, len)).append("...\"").toString();
} else { } else {
debugString = " null text"; debugString = " null text";
} }
@ -124,9 +118,8 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
new StringBuilder().append(e.getLocalizedMessage()) new StringBuilder().append(e.getLocalizedMessage())
.append(optionalFieldInfo).append(debugString)); .append(optionalFieldInfo).append(debugString));
} else { } else {
throw new SolrException(ErrorCode.SERVER_ERROR, new StringBuilder( throw new SolrException(ErrorCode.SERVER_ERROR, "processing error " + e.getLocalizedMessage() +
"processing error ").append(e.getLocalizedMessage()) optionalFieldInfo + debugString, e);
.append(optionalFieldInfo).append(debugString).toString(), e);
} }
} }
super.processAdd(cmd); super.processAdd(cmd);
@ -142,16 +135,27 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
if (merge) { if (merge) {
StringBuilder unifiedText = new StringBuilder(""); StringBuilder unifiedText = new StringBuilder("");
for (String aFieldsToAnalyze : fieldsToAnalyze) { for (String aFieldsToAnalyze : fieldsToAnalyze) {
unifiedText.append(String.valueOf(solrInputDocument if (solrInputDocument.getFieldValues(aFieldsToAnalyze) != null) {
.getFieldValue(aFieldsToAnalyze))); Object[] Values = solrInputDocument.getFieldValues(aFieldsToAnalyze).toArray();
for (Object Value : Values) {
if (unifiedText.length() > 0) {
unifiedText.append(' ');
}
unifiedText.append(Value.toString());
}
}
} }
textVals = new String[1]; textVals = new String[1];
textVals[0] = unifiedText.toString(); textVals[0] = unifiedText.toString();
} else { } else {
textVals = new String[fieldsToAnalyze.length]; textVals = new String[fieldsToAnalyze.length];
for (int i = 0; i < fieldsToAnalyze.length; i++) { for (int i = 0; i < fieldsToAnalyze.length; i++) {
textVals[i] = String.valueOf(solrInputDocument if (solrInputDocument.getFieldValues(fieldsToAnalyze[i]) != null) {
.getFieldValue(fieldsToAnalyze[i])); Object[] Values = solrInputDocument.getFieldValues(fieldsToAnalyze[i]).toArray();
for (Object Value : Values) {
textVals[i] += Value.toString();
}
}
} }
} }
return textVals; return textVals;