Skip to content

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

changed strategy to count the number of documents: get the max of solr+buffer and the hit cache. This shall help during first crawls to see a running document counter even if there was no commit meanwhile to solr. To support that strategy, the hit cache must be written earlier.

Michael Peter Christen395edec6f146
diff --git a/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java
index 5cb6331b4..1d7489ca3 100644
--- a/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java
+++ b/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java
@@ -117,10 +117,6 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
- // move documents to metadata cache
- for (Map.Entry<String, SolrInputDocument> entry: this.docBuffer.entrySet()) {
- updateCache(entry.getKey(), AbstractSolrConnector.getLoadTimeURL(entry.getValue()));
- }
this.docBuffer.clear();
}
}
@@ -162,7 +158,7 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
@Override
public long getSize() {
- return this.connector.getSize() + this.docBuffer.size();
+ return Math.max(this.metadataCache.size(), this.connector.getSize() + this.docBuffer.size());
}
@Override
@@ -266,13 +262,12 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
@Override
public void add(SolrInputDocument solrdoc) throws IOException, SolrException {
String id = (String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName());
- this.metadataCache.remove(id); // remove the id from the metadata cache because it will be overwritten by the update process anyway
+ updateCache(id, AbstractSolrConnector.getLoadTimeURL(solrdoc));
ensureAliveProcessHandler();
if (this.processHandler.isAlive()) {
synchronized (this.docBuffer) {this.docBuffer.put(id, solrdoc);}
} else {
this.connector.add(solrdoc);
- updateCache(id, AbstractSolrConnector.getLoadTimeURL(solrdoc));
}
if (MemoryControl.shortStatus() || this.docBuffer.size() > this.updateCapacity) {
commitDocBuffer();
@@ -285,6 +280,7 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
synchronized (this.docBuffer) {
for (SolrInputDocument solrdoc: solrdocs) {
String id = (String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName());
+ updateCache(id, AbstractSolrConnector.getLoadTimeURL(solrdoc));
if (this.processHandler.isAlive()) {
this.docBuffer.put(id, solrdoc);
} else {