mirror of https://github.com/apache/lucene.git
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:
parent
3e89362436
commit
eee9bd713f
|
@ -17,8 +17,6 @@ package org.apache.solr.uima.processor;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
|
import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
|
||||||
import org.apache.uima.cas.FSIterator;
|
import org.apache.uima.cas.FSIterator;
|
||||||
|
@ -29,6 +27,8 @@ import org.apache.uima.jcas.tcas.Annotation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map UIMA types and features over fields of a Solr document
|
* Map UIMA types and features over fields of a Solr document
|
||||||
*
|
*
|
||||||
|
@ -64,16 +64,18 @@ public class UIMAToSolrMapper {
|
||||||
String fieldNameFeatureValue = fieldNameFeature == null ? null :
|
String fieldNameFeatureValue = fieldNameFeature == null ? null :
|
||||||
fs.getFeatureValueAsString(type.getFeatureByBaseName(fieldNameFeature));
|
fs.getFeatureValueAsString(type.getFeatureByBaseName(fieldNameFeature));
|
||||||
String fieldName = mapField.getFieldName(fieldNameFeatureValue);
|
String fieldName = mapField.getFieldName(fieldNameFeatureValue);
|
||||||
log.info(new StringBuilder("mapping ").append(typeName).append("@").append(featureName)
|
if (log.isInfoEnabled()) {
|
||||||
.append(" to ").append(fieldName).toString());
|
log.info("mapping {}@{} to {}", new Object[]{typeName, featureName, fieldName});
|
||||||
|
}
|
||||||
String featureValue;
|
String featureValue;
|
||||||
if (fs instanceof Annotation && "coveredText".equals(featureName)) {
|
if (fs instanceof Annotation && "coveredText".equals(featureName)) {
|
||||||
featureValue = ((Annotation) fs).getCoveredText();
|
featureValue = ((Annotation) fs).getCoveredText();
|
||||||
} else {
|
} else {
|
||||||
featureValue = fs.getFeatureValueAsString(type.getFeatureByBaseName(featureName));
|
featureValue = fs.getFeatureValueAsString(type.getFeatureByBaseName(featureName));
|
||||||
}
|
}
|
||||||
log.info(new StringBuilder("writing ").append(featureValue).append(" in ").append(
|
if (log.isDebugEnabled()) {
|
||||||
fieldName).toString());
|
log.debug("writing {} in {}", new Object[]{featureValue, fieldName});
|
||||||
|
}
|
||||||
document.addField(fieldName, featureValue, 1.0f);
|
document.addField(fieldName, featureValue, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,9 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
||||||
debugString = " null text";
|
debugString = " null text";
|
||||||
}
|
}
|
||||||
if (solrUIMAConfiguration.isIgnoreErrors()) {
|
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(e.getLocalizedMessage()).append(optionalFieldInfo)
|
||||||
.append(debugString).toString());
|
.append(debugString));
|
||||||
} else {
|
} else {
|
||||||
throw new SolrException(ErrorCode.SERVER_ERROR,
|
throw new SolrException(ErrorCode.SERVER_ERROR,
|
||||||
new StringBuilder("processing 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 */
|
/* process a field value executing UIMA the CAS containing it as document text */
|
||||||
private JCas processText(String textFieldValue) throws ResourceInitializationException,
|
private JCas processText(String textFieldValue) throws ResourceInitializationException,
|
||||||
AnalysisEngineProcessException {
|
AnalysisEngineProcessException {
|
||||||
log.info(new StringBuilder("Analyzing text").toString());
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Analyzing text");
|
||||||
|
}
|
||||||
/* get the UIMA analysis engine */
|
/* get the UIMA analysis engine */
|
||||||
AnalysisEngine ae = aeProvider.getAE();
|
AnalysisEngine ae = aeProvider.getAE();
|
||||||
|
|
||||||
|
@ -160,7 +162,9 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
||||||
|
|
||||||
/* perform analysis on text field */
|
/* perform analysis on text field */
|
||||||
ae.process(jcas);
|
ae.process(jcas);
|
||||||
log.info("Text processing completed");
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Text processing completed");
|
||||||
|
}
|
||||||
return jcas;
|
return jcas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue