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