SOLR-2582: Use uniqueKey for error log in UIMAUpdateRequestProcessor

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1135011 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Koji Sekiguchi 2011-06-13 02:37:57 +00:00
parent 52e432be3a
commit 0e96bce83e
4 changed files with 18 additions and 3 deletions

View File

@ -24,6 +24,12 @@ $Id$
(No Changes) (No Changes)
================== 3.3.0-dev ============== ================== 3.3.0-dev ==============
New Features
----------------------
* SOLR-2582: Use uniqueKey for error log in UIMAUpdateRequestProcessor.
(Tommaso Teofili via koji)
Bug Fixes Bug Fixes
---------------------- ----------------------

View File

@ -35,8 +35,9 @@ To start using Solr UIMA Metadata Extraction Library you should go through the f
never indexed documents entirely in your session. --> never indexed documents entirely in your session. -->
<bool name="ignoreErrors">true</bool> <bool name="ignoreErrors">true</bool>
<!-- This is optional. It is used for logging when text processing fails. <!-- This is optional. It is used for logging when text processing fails.
Usually, set uniqueKey field name --> If logField is not specified, uniqueKey will be used as logField.
<str name="logField">id</str> <str name="logField">id</str>
-->
<lst name="analyzeFields"> <lst name="analyzeFields">
<bool name="merge">false</bool> <bool name="merge">false</bool>
<arr name="fields"> <arr name="fields">

View File

@ -21,6 +21,7 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField; import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
import org.apache.solr.uima.processor.ae.AEProvider; import org.apache.solr.uima.processor.ae.AEProvider;
import org.apache.solr.uima.processor.ae.AEProviderFactory; import org.apache.solr.uima.processor.ae.AEProviderFactory;
@ -44,6 +45,8 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
SolrUIMAConfiguration solrUIMAConfiguration; SolrUIMAConfiguration solrUIMAConfiguration;
private AEProvider aeProvider; private AEProvider aeProvider;
private SolrCore solrCore;
public UIMAUpdateRequestProcessor(UpdateRequestProcessor next, SolrCore solrCore, public UIMAUpdateRequestProcessor(UpdateRequestProcessor next, SolrCore solrCore,
SolrUIMAConfiguration config) { SolrUIMAConfiguration config) {
@ -52,6 +55,7 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
} }
private void initialize(SolrCore solrCore, SolrUIMAConfiguration config) { private void initialize(SolrCore solrCore, SolrUIMAConfiguration config) {
this.solrCore = solrCore;
solrUIMAConfiguration = config; solrUIMAConfiguration = config;
aeProvider = AEProviderFactory.getInstance().getAEProvider(solrCore.getName(), aeProvider = AEProviderFactory.getInstance().getAEProvider(solrCore.getName(),
solrUIMAConfiguration.getAePath(), solrUIMAConfiguration.getRuntimeParameters()); solrUIMAConfiguration.getAePath(), solrUIMAConfiguration.getRuntimeParameters());
@ -84,6 +88,12 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
String logField = solrUIMAConfiguration.getLogField(); String logField = solrUIMAConfiguration.getLogField();
if(logField == null){
SchemaField uniqueKeyField = solrCore.getSchema().getUniqueKeyField();
if(uniqueKeyField != null){
logField = uniqueKeyField.getName();
}
}
String optionalFieldInfo = logField == null ? "." : String optionalFieldInfo = logField == null ? "." :
new StringBuilder(". ").append(logField).append("=") new StringBuilder(". ").append(logField).append("=")
.append((String)cmd.getSolrInputDocument().getField(logField).getValue()) .append((String)cmd.getSolrInputDocument().getField(logField).getValue())

View File

@ -1064,8 +1064,6 @@
</lst> </lst>
<str name="analysisEngine">/TestExceptionAE.xml</str> <str name="analysisEngine">/TestExceptionAE.xml</str>
<bool name="ignoreErrors">true</bool> <bool name="ignoreErrors">true</bool>
<!-- This is optional. It is used for logging when text processing fails. Usually, set uniqueKey field name -->
<str name="logField">id</str>
<lst name="analyzeFields"> <lst name="analyzeFields">
<bool name="merge">false</bool> <bool name="merge">false</bool>
<arr name="fields"> <arr name="fields">