SOLR-4865 - improved UIMA URP logging

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1486792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tommaso Teofili 2013-05-28 07:35:33 +00:00
parent 3e89362436
commit eee9bd713f
2 changed files with 16 additions and 10 deletions

View File

@ -17,8 +17,6 @@ package org.apache.solr.uima.processor;
* limitations under the License.
*/
import java.util.Map;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
import org.apache.uima.cas.FSIterator;
@ -29,6 +27,8 @@ import org.apache.uima.jcas.tcas.Annotation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
/**
* Map UIMA types and features over fields of a Solr document
*
@ -64,16 +64,18 @@ public class UIMAToSolrMapper {
String fieldNameFeatureValue = fieldNameFeature == null ? null :
fs.getFeatureValueAsString(type.getFeatureByBaseName(fieldNameFeature));
String fieldName = mapField.getFieldName(fieldNameFeatureValue);
log.info(new StringBuilder("mapping ").append(typeName).append("@").append(featureName)
.append(" to ").append(fieldName).toString());
if (log.isInfoEnabled()) {
log.info("mapping {}@{} to {}", new Object[]{typeName, featureName, fieldName});
}
String featureValue;
if (fs instanceof Annotation && "coveredText".equals(featureName)) {
featureValue = ((Annotation) fs).getCoveredText();
} else {
featureValue = fs.getFeatureValueAsString(type.getFeatureByBaseName(featureName));
}
log.info(new StringBuilder("writing ").append(featureValue).append(" in ").append(
fieldName).toString());
if (log.isDebugEnabled()) {
log.debug("writing {} in {}", new Object[]{featureValue, fieldName});
}
document.addField(fieldName, featureValue, 1.0f);
}
}

View File

@ -111,9 +111,9 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
debugString = " null text";
}
if (solrUIMAConfiguration.isIgnoreErrors()) {
log.warn(new StringBuilder("skip the text processing due to ")
log.warn("skip the text processing due to {}",new StringBuilder()
.append(e.getLocalizedMessage()).append(optionalFieldInfo)
.append(debugString).toString());
.append(debugString));
} else {
throw new SolrException(ErrorCode.SERVER_ERROR,
new StringBuilder("processing error ")
@ -150,7 +150,9 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
/* process a field value executing UIMA the CAS containing it as document text */
private JCas processText(String textFieldValue) throws ResourceInitializationException,
AnalysisEngineProcessException {
log.info(new StringBuilder("Analyzing text").toString());
if (log.isDebugEnabled()) {
log.debug("Analyzing text");
}
/* get the UIMA analysis engine */
AnalysisEngine ae = aeProvider.getAE();
@ -160,7 +162,9 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
/* perform analysis on text field */
ae.process(jcas);
log.info("Text processing completed");
if (log.isDebugEnabled()) {
log.debug("Text processing completed");
}
return jcas;
}