Skip to content

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

enhanced postprocessing by usage of a field-list generation to prevent lazy initialization of the documents. This is useful because the documents must be read completely anyway.

orbiter71758f0d62fd
diff --git a/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java
index eaaf8fcdd..fd9114567 100644
--- a/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java
+++ b/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java
@@ -461,14 +461,15 @@ public abstract class AbstractSolrConnector implements SolrConnector {
query.clearSorts();
query.setRows(1);
query.setStart(0);
- if (fields.length > 0) query.setFields(fields);
+ if (fields != null && fields.length > 0) query.setFields(fields);
query.setIncludeScore(false);
// query the server
try {
final SolrDocumentList docs = getDocumentListByParams(query);
if (docs == null || docs.isEmpty()) return null;
- return docs.get(0);
+ SolrDocument doc = docs.get(0);
+ return doc;
} catch (final Throwable e) {
clearCaches(); // we clear the in case that this is caused by OOM
throw new IOException(e.getMessage(), e);
diff --git a/source/net/yacy/search/schema/CollectionConfiguration.java b/source/net/yacy/search/schema/CollectionConfiguration.java
index 50803695a..8c7b8bd7d 100644
--- a/source/net/yacy/search/schema/CollectionConfiguration.java
+++ b/source/net/yacy/search/schema/CollectionConfiguration.java
@@ -146,6 +146,14 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
}
}
+
+ public String[] allFields() {
+ ArrayList<String> a = new ArrayList<>(this.size());
+ for (CollectionSchema f: CollectionSchema.values()) {
+ if (this.contains(f)) a.add(f.getSolrFieldName());
+ }
+ return a.toArray(new String[a.size()]);
+ }
public Ranking getRanking(final int idx) {
return this.rankings.get(idx % this.rankings.size()); // simply prevent out of bound exeption (& callers don't check for null)
@@ -1267,6 +1275,9 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
0, 100000000, Long.MAX_VALUE, concurrency + 1, concurrency, true,
byPartialUpdate ?
new String[]{
+ // the following fields are needed to perform the postprocessing
+ // and should only be used for partial updates; for full updates use a
+ // full list of fields to avoid LazyInstantiation which has poor performace
CollectionSchema.id.getSolrFieldName(),
CollectionSchema.sku.getSolrFieldName(),
CollectionSchema.harvestkey_s.getSolrFieldName(),
@@ -1285,7 +1296,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
CollectionSchema.httpstatus_i.getSolrFieldName(),
CollectionSchema.inboundlinkscount_i.getSolrFieldName(),
CollectionSchema.robots_i.getSolrFieldName()} :
- new String[0]);
+ this.allFields());
final AtomicInteger proccount = new AtomicInteger();
final AtomicInteger proccount_referencechange = new AtomicInteger();
final AtomicInteger proccount_citationchange = new AtomicInteger();