Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-4865 - improved UIMA URP logging

Tommaso Teofilieee9bd713fe9
diff --git a/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAToSolrMapper.java b/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAToSolrMapper.java
index 77dcceae79d..a4b3e7aea58 100644
--- a/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAToSolrMapper.java
+++ b/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAToSolrMapper.java
@@ -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);
}
}
diff --git a/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java b/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
index e8fec2ecd70..c7ef117751a 100644
--- a/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
+++ b/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
@@ -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;
}