diff --git a/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java b/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java index 74e811eaa..e1d3e3795 100644 --- a/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java +++ b/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java @@ -41,9 +41,17 @@ import org.apache.solr.common.SolrInputDocument; public class AbstractSolrConnector implements SolrConnector { + private final static SolrQuery catchallQuery = new SolrQuery(); + static { + catchallQuery.setQuery("*:*"); + catchallQuery.setFields(YaCySchema.id.name()); + catchallQuery.setRows(1); + catchallQuery.setStart(0); + } + protected SolrServer server; protected int commitWithinMs; // max time (in ms) before a commit will happen - + protected AbstractSolrConnector() { this.server = null; this.commitWithinMs = 180000; @@ -90,8 +98,11 @@ public class AbstractSolrConnector implements SolrConnector { @Override public long getSize() { try { - final SolrDocumentList list = query("*:*", 0, 1); - return list.getNumFound(); + final QueryResponse rsp = this.server.query(catchallQuery); + if (rsp == null) return 0; + final SolrDocumentList docs = rsp.getResults(); + if (docs == null) return 0; + return docs.getNumFound(); } catch (final Throwable e) { Log.logException(e); return 0; diff --git a/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java b/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java index 27418e14b..c8001e5dd 100644 --- a/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java +++ b/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java @@ -173,6 +173,7 @@ public class RetrySolrConnector implements SolrConnector { while (System.currentTimeMillis() < t) try { return this.solrConnector.getSize(); } catch (final Throwable e) { + try {Thread.sleep(10);} catch (final InterruptedException e1) {} continue; } return 0; diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index 889273084..3e1ec43c5 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -2930,8 +2930,9 @@ public final class Switchboard extends serverSwitch return "no DHT distribution: not enabled (per setting)"; } final Segment indexSegment = this.index; - if ( indexSegment.urlMetadata().size() < 10 ) { - return "no DHT distribution: loadedURL.size() = " + indexSegment.urlMetadata().size(); + int size = indexSegment.urlMetadata().size(); + if ( size < 10 ) { + return "no DHT distribution: loadedURL.size() = " + size; } if ( indexSegment.termIndex().sizesMax() < 100 ) { return "no DHT distribution: not enough words - wordIndex.size() = " diff --git a/source/net/yacy/search/solr/EmbeddedSolrConnector.java b/source/net/yacy/search/solr/EmbeddedSolrConnector.java index 85988788d..5d4352a9d 100644 --- a/source/net/yacy/search/solr/EmbeddedSolrConnector.java +++ b/source/net/yacy/search/solr/EmbeddedSolrConnector.java @@ -114,7 +114,13 @@ public class EmbeddedSolrConnector extends AbstractSolrConnector implements Solr public SolrConfig getConfig() { return this.defaultCore.getSolrConfig(); } - + + @Override + public long getSize() { + // do some magic here to prevent the super.getSize() call which is a bad hack + return super.getSize(); + } + @Override public synchronized void close() { super.close();