Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

enhancement to solr caching: consider that during a get() the document is not in solr but the cache points out that a commit is needed to get the document.

Michael Peter Christen96912c947180
diff --git a/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java
index e93f3e28d..5cc2aa507 100644
--- a/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java
+++ b/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java
@@ -162,10 +162,10 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
*/
@Override
public void delete(final String id) throws IOException {
+ this.documentCache.remove(id);
this.hitCache.remove(id);
this.missCache.put(id, EXIST);
this.missCache_Insert++;
- this.documentCache.remove(id);
if (this.solr0 != null) this.solr0.delete(id);
if (this.solr1 != null) this.solr1.delete(id);
}
@@ -178,10 +178,10 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
@Override
public void delete(final List<String> ids) throws IOException {
for (String id: ids) {
+ this.documentCache.remove(id);
this.hitCache.remove(id);
this.missCache.put(id, EXIST);
this.missCache_Insert++;
- this.documentCache.remove(id);
}
if (this.solr0 != null) this.solr0.delete(ids);
if (this.solr1 != null) this.solr1.delete(ids);
@@ -249,6 +249,19 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
this.documentCache_Insert++;
return doc;
}
+ // check if there is a autocommit problem
+ if (this.hitCache.containsKey(id)) {
+ // the document should be there, therefore make a commit and check again
+ this.commit();
+ if ((solr0 != null && ((doc = solr0.get(id)) != null)) || (solr1 != null && ((doc = solr1.get(id)) != null))) {
+ this.missCache.remove(id);
+ this.hitCache.put(id, EXIST);
+ this.hitCache_Insert++;
+ this.documentCache.put(id, doc);
+ this.documentCache_Insert++;
+ return doc;
+ }
+ }
this.missCache.put(id, EXIST);
this.missCache_Insert++;
return null;