adapt SolrServerConnector.add to handle error on partial update input document.

In case of error we deleted the original document and added the new doc to the index.
This is not valid for partial update documents (which contain only a subset of the fields).
Remove the "delete" error handling step.
pull/14/head
reger 10 years ago
parent e594130aec
commit b4cbdea1e7

@ -216,11 +216,14 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
clearCaches(); // prevent further OOM if this was caused by OOM clearCaches(); // prevent further OOM if this was caused by OOM
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
// catches "version conflict for": try this again and delete the document in advance // catches "version conflict for": try this again and delete the document in advance
/*
// with possible partial update docs, don't try to delete index doc and reinsert solrdoc
// as this would result in a index doc with just the updated fields
try { try {
this.server.deleteById((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName())); this.server.deleteById((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
} catch (final SolrServerException e1) { } catch (final SolrServerException e1) {
ConcurrentLog.logException(e1); ConcurrentLog.logException(e1);
} }*/
try { try {
this.server.add(solrdoc, -1); this.server.add(solrdoc, -1);
} catch (final Throwable ee) { } catch (final Throwable ee) {
@ -255,13 +258,17 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
clearCaches(); // prevent further OOM if this was caused by OOM clearCaches(); // prevent further OOM if this was caused by OOM
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
// catches "version conflict for": try this again and delete the document in advance // catches "version conflict for": try this again and delete the document in advance
/*
// with possible partial update docs, don't try to delete index doc and reinsert solrdoc
// as this would result in a index doc with just the updated fields
List<String> ids = new ArrayList<String>(); List<String> ids = new ArrayList<String>();
for (SolrInputDocument solrdoc : solrdocs) ids.add((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName())); for (SolrInputDocument solrdoc : solrdocs) ids.add((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
try { try {
this.server.deleteById(ids); this.server.deleteById(ids);
} catch (final SolrServerException e1) { } catch (final SolrServerException e1) {
ConcurrentLog.logException(e1); ConcurrentLog.logException(e1);
} }*/
try { try {
this.server.commit(); this.server.commit();
} catch (final Throwable eee) { } catch (final Throwable eee) {
@ -272,6 +279,8 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
this.server.add(solrdocs, -1); this.server.add(solrdocs, -1);
} catch (final Throwable ee) { } catch (final Throwable ee) {
ConcurrentLog.logException(ee); ConcurrentLog.logException(ee);
List<String> ids = new ArrayList<String>();
for (SolrInputDocument solrdoc : solrdocs) ids.add((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
log.warn(e.getMessage() + " IDs=" + ids.toString()); log.warn(e.getMessage() + " IDs=" + ids.toString());
throw new IOException(ee); throw new IOException(ee);
} }

Loading…
Cancel
Save