Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
introduced a second core named 'webgraph'. This core will hold the link structure, but is not filled yet. To have the opportunity of a second core, multi-core functionality had to be implemented to the deep-embedded solr: - migrated the solr_40 directory content to a subdirectory 'collection1'; the previously used default core is now called collection1 - added solr_40/webgraph subdirectory as second core - added a servlet configuration for the second core 'webgraph' in /IndexSchema_p.html - added instance handling as addition to solr connections: all solr connectors are now instances of an solr 'instance' object; this required a complete re-design of the solr embedding - migrated also caching and sharding ontop of new instance handling - migrated the search apis to handle now the access to a specific core, the default core named 'collection1' - migrated the remote solr search interface to access shards of cores; for the yacy remote search the default core is now called 'solr'; using the peer address as solr address - migrated the solr backup and restore process: old backups cannot be used after this migration! - redesign of solr instance handling in all methods which access the instances: they cannot hold copies of these instances any more; the must retrieve the actuall connection object every time they want to write to it (this solves also some bugs when switching the index/network) - added another schema 'solr.webgraph.schema', the old solr.keys.list is replaced by solr.collection.schema
Michael Peter Christen91a0401d5943
diff --git a/defaults/solr.keys.list b/defaults/solr.collection.schemasimilarity index 97%rename from defaults/solr.keys.listrename to defaults/solr.collection.schemaindex d73fab485..bc045020c 100644--- a/defaults/solr.keys.list+++ b/defaults/solr.collection.schema@@ -1,8 +1,6 @@-## this is a list of all solr keys-## solr can be used as alternative index target, solr is NOT the primary indexing system of YaCy-## this complete list of keys can be reduced:-## reduced list of keys can be placed in DATA/SETTINGS/solr.keys.<profile>.list-## where they can be used as profiles for solr index transport+## this is a list of all solr keys for the default index 'collection1', the fulltext search index+## this complete list of keys can be changed; the actual schema is stored in:+## DATA/SETTINGS/solr.collection.schema## the syntax of this file:## - all lines beginning with '##' are commentsdiff --git a/defaults/solr.webgraph.schema b/defaults/solr.webgraph.schemanew file mode 100644index 000000000..f48931681--- /dev/null+++ b/defaults/solr.webgraph.schema@@ -0,0 +1,172 @@+## this is a list of all solr keys for the webgraph index 'webgraph', an index of all links+## this complete list of keys can be changed; the actual schema is stored in:+## DATA/SETTINGS/solr.webgraph.schema++## the syntax of this file:+## - all lines beginning with '##' are comments+## - all non-empty lines not beginning with '#' are keyword lines+## - all lines beginning with '#' and where the second character is not '#' are commented-out keyword lines+++##+## document organization+##++## primary key of document, a combination of <source-url-hash><target-url-hash><four-digit-hex-counter> (28 characters)+id++## tags that are attached to crawls/index generation to separate the search result into user-defined subsets+collection_sxt+++##+## url construction information about the source+##++## primary key of document, the URL hash (source)+source_id_s++## the url of the document (source)+#source_url_s++## the file name extension (source)+#source_file_ext_s++## normalized (absolute URLs), as <a> - tag with anchor text and nofollow (source)+#source_tag_s++## number of all characters in the url (source)+#source_chars_i++## the protocol of the url (source)+#source_protocol_s++## path of the url (source)+#source_path_s++## count of all path elements in the url (source)+#source_path_folders_count_i++## all path elements in the url (source)+#source_path_folders_sxt++## number of key-value pairs in search part of the url (source)+#source_parameter_count_i++## the keys from key-value pairs in the search part of the url (source)+#source_parameter_key_sxt++## the values from key-value pairs in the search part of the url (source)+#source_parameter_value_sxt++## depth of web page according to number of clicks from the 'main' page, which is the page that appears if only the host is entered as url (source)+#source_clickdepth_i++## host of the url+#source_host_s++## the Domain Class Name, either the TLD or a combination of ccSLD+TLD if a ccSLD is used (source)+#source_host_dnc_s++## either the second level domain or, if a ccSLD is used, the third level domain+#source_host_organization_s++## the organization and dnc concatenated with '.' (source)+#source_host_organizationdnc_s++## the remaining part of the host without organizationdnc (source)+#source_host_subdomain_s+++##+## Information in the source about the target+##++## the text content of the a-tag (in source, but pointing to a target)+target_linktext_t++## the length of the a-tag content text as number of characters (in source, but pointing to a target)+#target_linktext_charcount_i++## the length of the a-tag content text as number of words (in source, but pointing to a target)+#target_linktext_wordcount_i++## if the link is an image link, this contains the alt tag if the image is also liked as img link (in source, but pointing to a target)+target_alt_t++## the length of the a-tag content text as number of characters (in source, but pointing to a target)+#target_alt_charcount_i++## the length of the a-tag content text as number of words (in source, but pointing to a target)+#target_alt_wordcount_i++## the name property of the a-tag (in source, but pointing to a target)+target_name_t++## the rel property of the a-tag (in source, but pointing to a target)+#target_rel_s++## the rel property of the a-tag, coded binary (in source, but pointing to a target)+#target_relflags_i+++##+## url construction information about the target+##++## primary key of document, the URL hash (target)+target_id_s++## the url of the document (target)+target_url_s++## the file name extension (target)+target_file_ext_s++## normalized (absolute URLs), as <a> - tag with anchor text and nofollow (target)+#target_tag_s++## number of all characters in the url (target)+#target_chars_i++## the protocol of the url (target)+target_protocol_s++## path of the url (target)+#target_path_s++## count of all path elements in the url (target)+#target_path_folders_count_i++## all path elements in the url (target)+target_path_folders_sxt++## number of key-value pairs in search part of the url (target)+#target_parameter_count_i++## the keys from key-value pairs in the search part of the url (target)+#target_parameter_key_sxt++## the values from key-value pairs in the search part of the url (target)+#target_parameter_value_sxt++## "depth of web page according to number of clicks from the 'main' page, which is the page that appears if only the host is entered as url (target)+#target_clickdepth_i++## host of the url (target)+#target_host_s++## the Domain Class Name, either the TLD or a combination of ccSLD+TLD if a ccSLD is used (target)+#target_host_dnc_s++## either the second level domain or, if a ccSLD is used, the third level domain (target)+#target_host_organization_s++## the organization and dnc concatenated with '.' (target)+#target_host_organizationdnc_s++## the remaining part of the host without organizationdnc (target)+#target_host_subdomain_s+++diff --git a/defaults/solr/solr.xml b/defaults/solr/solr.xmlindex 6d4d9f0e1..dbe011f6e 100644--- a/defaults/solr/solr.xml+++ b/defaults/solr/solr.xml@@ -1,6 +1,10 @@<?xml version="1.0" encoding="UTF-8" ?><solr persistent="false">+ <logging enabled="true">+ <watcher size="100" threshold="INFO" />+ </logging><cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}" hostPort="${jetty.port:}">- <core name="collection1" instanceDir="." />+ <core name="collection1" instanceDir="collection1" />+ <core name="webgraph" instanceDir="webgraph" /></cores></solr>diff --git a/defaults/yacy.init b/defaults/yacy.initindex 751aa379e..3bae2731d 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -1057,7 +1057,6 @@ color_searchurlhover = #008000federated.service.solr.indexing.enabled = falsefederated.service.solr.indexing.url = http://127.0.0.1:8983/solrfederated.service.solr.indexing.sharding = MODULO_HOST_MD5-federated.service.solr.indexing.schemefile = solr.keys.default.list# the lazy attribute causes that fields containing "" or 0 are not added and not writtenfederated.service.solr.indexing.lazy = truediff --git a/htroot/ConfigHeuristics_p.java b/htroot/ConfigHeuristics_p.javaindex bdcc3a0b0..32af59772 100644--- a/htroot/ConfigHeuristics_p.java+++ b/htroot/ConfigHeuristics_p.java@@ -30,11 +30,12 @@ import java.io.File;import net.yacy.cora.protocol.RequestHeader;import net.yacy.data.WorkTables;import net.yacy.search.Switchboard;+import net.yacy.search.schema.CollectionSchema;+import java.io.IOException;import java.util.Iterator;-import net.yacy.cora.federate.yacy.ConfigurationSet;import net.yacy.cora.federate.opensearch.OpenSearchConnector;-import net.yacy.cora.federate.solr.YaCySchema;+import net.yacy.cora.federate.solr.SchemaConfiguration;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -72,7 +73,7 @@ public class ConfigHeuristics_p {}if (post.containsKey("opensearch_off")) sb.setConfig("heuristic.opensearch", false);if (post.containsKey("discoverosd")) {- final boolean metafieldNOTavailable = sb.index.fulltext().getSolrSchema().containsDisabled(YaCySchema.outboundlinks_tag_txt.name());+ final boolean metafieldNOTavailable = sb.index.fulltext().getDefaultConfiguration().containsDisabled(CollectionSchema.outboundlinks_tag_txt.name());if (!metafieldNOTavailable) {OpenSearchConnector osc = new OpenSearchConnector(sb, false);if (osc.discoverFromSolrIndex(sb)) {@@ -107,19 +108,19 @@ public class ConfigHeuristics_p {}if (post.containsKey("switchsolrfieldson")) {- final boolean metafieldNOTavailable = sb.index.fulltext().getSolrSchema().containsDisabled(YaCySchema.outboundlinks_tag_txt.name());+ final boolean metafieldNOTavailable = sb.index.fulltext().getDefaultConfiguration().containsDisabled(CollectionSchema.outboundlinks_tag_txt.name());if (metafieldNOTavailable) {- ConfigurationSet.Entry entry;- entry = sb.index.fulltext().getSolrSchema().get(YaCySchema.outboundlinks_tag_txt.name());+ SchemaConfiguration.Entry entry;+ entry = sb.index.fulltext().getDefaultConfiguration().get(CollectionSchema.outboundlinks_tag_txt.name());if (entry != null && !entry.enabled()) {entry.setEnable(true);}- entry = sb.index.fulltext().getSolrSchema().get(YaCySchema.inboundlinks_tag_txt.name());+ entry = sb.index.fulltext().getDefaultConfiguration().get(CollectionSchema.inboundlinks_tag_txt.name());if (entry != null && !entry.enabled()) {entry.setEnable(true);}try {- sb.index.fulltext().getSolrSchema().commit();+ sb.index.fulltext().getDefaultConfiguration().commit();} catch (IOException ex) {}}}@@ -139,7 +140,7 @@ public class ConfigHeuristics_p {}}- final boolean showmetafieldbutton = sb.index.fulltext().getSolrSchema().containsDisabled(YaCySchema.outboundlinks_tag_txt.name());+ final boolean showmetafieldbutton = sb.index.fulltext().getDefaultConfiguration().containsDisabled(CollectionSchema.outboundlinks_tag_txt.name());if (showmetafieldbutton) prop.put("osdsolrfieldswitch",1);prop.put("site.checked", sb.getConfigBool("heuristic.site", false) ? 1 : 0);prop.put("searchresult.checked", sb.getConfigBool("heuristic.searchresults", false) ? 1 : 0);@@ -150,12 +151,12 @@ public class ConfigHeuristics_p {// display config file contentfinal File f = new File (sb.getDataPath(),"DATA/SETTINGS/heuristicopensearch.conf");- ConfigurationSet p = new ConfigurationSet(f);+ SchemaConfiguration p = new SchemaConfiguration(f);int c = 0;boolean dark = false;- Iterator<ConfigurationSet.Entry> i = p.entryIterator();+ Iterator<SchemaConfiguration.Entry> i = p.entryIterator();while (i.hasNext()) {- ConfigurationSet.Entry e = i.next();+ SchemaConfiguration.Entry e = i.next();prop.put("osdcfg_" + c + "_dark", dark ? 1 : 0);dark = !dark;prop.put("osdcfg_" + c + "_checked", e.enabled() ? 1 : 0);@@ -178,9 +179,9 @@ public class ConfigHeuristics_p {// read index schema table flagsfinal File f = new File(sb.getDataPath(), "DATA/SETTINGS/heuristicopensearch.conf");- ConfigurationSet cfg = new ConfigurationSet(f);- final Iterator<ConfigurationSet.Entry> cfgentries = cfg.entryIterator();- ConfigurationSet.Entry entry;+ SchemaConfiguration cfg = new SchemaConfiguration(f);+ final Iterator<SchemaConfiguration.Entry> cfgentries = cfg.entryIterator();+ SchemaConfiguration.Entry entry;boolean modified = false; // flag to remember changeswhile (cfgentries.hasNext()) {entry = cfgentries.next();diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.javaindex 5cc8b25f1..ec36321d1 100644--- a/htroot/CrawlResults.java+++ b/htroot/CrawlResults.java@@ -33,16 +33,15 @@ import java.util.Map;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.UTF8;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.protocol.RequestHeader;import net.yacy.crawler.data.ResultURLs;import net.yacy.crawler.data.ResultURLs.EventOrigin;import net.yacy.crawler.data.ResultURLs.InitExecEntry;-import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.data.meta.URIMetadataNode;import net.yacy.kelondro.logging.Log;import net.yacy.peers.Seed;import net.yacy.search.Switchboard;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;import net.yacy.utils.nxTools;@@ -55,7 +54,7 @@ public class CrawlResults {final serverObjects prop = new serverObjects();int lines = 500;- boolean showCollection = sb.index.fulltext().getSolrSchema().isEmpty() || sb.index.fulltext().getSolrSchema().contains(YaCySchema.collection_sxt);+ boolean showCollection = sb.index.fulltext().getDefaultConfiguration().isEmpty() || sb.index.fulltext().getDefaultConfiguration().contains(CollectionSchema.collection_sxt);boolean showInit = env.getConfigBool("IndexMonitorInit", false);boolean showExec = env.getConfigBool("IndexMonitorExec", false);boolean showDate = env.getConfigBool("IndexMonitorDate", true);diff --git a/htroot/CrawlStartExpert_p.java b/htroot/CrawlStartExpert_p.javaindex 0b3bd70a5..6a4425cf0 100644--- a/htroot/CrawlStartExpert_p.java+++ b/htroot/CrawlStartExpert_p.java@@ -24,11 +24,11 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.protocol.RequestHeader;import net.yacy.crawler.data.CrawlProfile;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -76,7 +76,7 @@ public class CrawlStartExpert_p {prop.put("xdstopwChecked", env.getConfigBool("xdstopw", true) ? "1" : "0");prop.put("xpstopwChecked", env.getConfigBool("xpstopw", true) ? "1" : "0");- boolean collectionEnabled = sb.index.fulltext().getSolrSchema().isEmpty() || sb.index.fulltext().getSolrSchema().contains(YaCySchema.collection_sxt);+ boolean collectionEnabled = sb.index.fulltext().getDefaultConfiguration().isEmpty() || sb.index.fulltext().getDefaultConfiguration().contains(CollectionSchema.collection_sxt);prop.put("collectionEnabled", collectionEnabled ? 1 : 0);prop.put("collection", collectionEnabled ? "user" : "");diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.javaindex eaedb7e71..fc76cf17b 100644--- a/htroot/Crawler_p.java+++ b/htroot/Crawler_p.java@@ -37,7 +37,6 @@ import java.util.regex.PatternSyntaxException;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.MultiProtocolURI;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.yacy.CacheStrategy;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.util.SpaceExceededException;@@ -58,6 +57,7 @@ import net.yacy.peers.NewsPool;import net.yacy.repository.Blacklist.BlacklistType;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -374,7 +374,7 @@ public class Crawler_p {sb.crawlQueues.errorURL.removeHost(hosthashes, true);for (byte[] hosthash: hosthashes) {try {- sb.index.fulltext().getSolr().deleteByQuery(YaCySchema.host_id_s.getSolrFieldName() + ":\"" + ASCII.String(hosthash) + "\" AND " + YaCySchema.failreason_t.getSolrFieldName() + ":[* TO *]");+ sb.index.fulltext().getDefaultConnector().deleteByQuery(CollectionSchema.host_id_s.getSolrFieldName() + ":\"" + ASCII.String(hosthash) + "\" AND " + CollectionSchema.failreason_t.getSolrFieldName() + ":[* TO *]");} catch (IOException e) {Log.logException(e);}}sb.index.fulltext().commit(true);diff --git a/htroot/HostBrowser.java b/htroot/HostBrowser.javaindex d6b73f081..3f9912fbf 100644--- a/htroot/HostBrowser.java+++ b/htroot/HostBrowser.java@@ -37,7 +37,6 @@ import net.yacy.cora.document.ASCII;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.solr.FailType;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.solr.connector.AbstractSolrConnector;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.sorting.ClusteredScoreMap;@@ -53,6 +52,7 @@ import net.yacy.kelondro.logging.Log;import net.yacy.peers.graphics.WebStructureGraph.StructureEntry;import net.yacy.search.Switchboard;import net.yacy.search.index.Fulltext;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -153,7 +153,7 @@ public class HostBrowser {int maxcount = admin ? 2 * 3 * 2 * 5 * 7 * 2 * 3 : 360; // which makes nice matrixes for 2, 3, 4, 5, 6, 7, 8, 9 rows/colums// collect hosts from index- ReversibleScoreMap<String> hostscore = fulltext.getSolr().getFacets("*:*", maxcount, YaCySchema.host_s.getSolrFieldName()).get(YaCySchema.host_s.getSolrFieldName());+ ReversibleScoreMap<String> hostscore = fulltext.getDefaultConnector().getFacets("*:*", maxcount, CollectionSchema.host_s.getSolrFieldName()).get(CollectionSchema.host_s.getSolrFieldName());if (hostscore == null) hostscore = new ClusteredScoreMap<String>();// collect hosts from crawler@@ -163,10 +163,10 @@ public class HostBrowser {}// collect the errorurls- Map<String, ReversibleScoreMap<String>> exclfacets = admin ? fulltext.getSolr().getFacets(YaCySchema.failtype_s.getSolrFieldName() + ":" + FailType.excl.name(), maxcount, YaCySchema.host_s.getSolrFieldName()) : null;- ReversibleScoreMap<String> exclscore = exclfacets == null ? new ClusteredScoreMap<String>() : exclfacets.get(YaCySchema.host_s.getSolrFieldName());- Map<String, ReversibleScoreMap<String>> failfacets = admin ? fulltext.getSolr().getFacets(YaCySchema.failtype_s.getSolrFieldName() + ":" + FailType.fail.name(), maxcount, YaCySchema.host_s.getSolrFieldName()) : null;- ReversibleScoreMap<String> failscore = failfacets == null ? new ClusteredScoreMap<String>() : failfacets.get(YaCySchema.host_s.getSolrFieldName());+ Map<String, ReversibleScoreMap<String>> exclfacets = admin ? fulltext.getDefaultConnector().getFacets(CollectionSchema.failtype_s.getSolrFieldName() + ":" + FailType.excl.name(), maxcount, CollectionSchema.host_s.getSolrFieldName()) : null;+ ReversibleScoreMap<String> exclscore = exclfacets == null ? new ClusteredScoreMap<String>() : exclfacets.get(CollectionSchema.host_s.getSolrFieldName());+ Map<String, ReversibleScoreMap<String>> failfacets = admin ? fulltext.getDefaultConnector().getFacets(CollectionSchema.failtype_s.getSolrFieldName() + ":" + FailType.fail.name(), maxcount, CollectionSchema.host_s.getSolrFieldName()) : null;+ ReversibleScoreMap<String> failscore = failfacets == null ? new ClusteredScoreMap<String>() : failfacets.get(CollectionSchema.host_s.getSolrFieldName());int c = 0;Iterator<String> i = hostscore.keys(false);@@ -235,26 +235,26 @@ public class HostBrowser {// get all files for a specific host from the indexStringBuilder q = new StringBuilder();- q.append(YaCySchema.host_s.getSolrFieldName()).append(':').append(host);+ q.append(CollectionSchema.host_s.getSolrFieldName()).append(':').append(host);if (pathparts.length > 0 && pathparts[0].length() > 0) {for (String pe: pathparts) {- if (pe.length() > 0) q.append(" AND ").append(YaCySchema.url_paths_sxt.getSolrFieldName()).append(":\"").append(pe).append('\"');+ if (pe.length() > 0) q.append(" AND ").append(CollectionSchema.url_paths_sxt.getSolrFieldName()).append(":\"").append(pe).append('\"');}} else {if (facetcount > 1000 || post.containsKey("nepr")) {- q.append(" AND ").append(YaCySchema.url_paths_sxt.getSolrFieldName()).append(":[* TO *]");+ q.append(" AND ").append(CollectionSchema.url_paths_sxt.getSolrFieldName()).append(":[* TO *]");}}- BlockingQueue<SolrDocument> docs = fulltext.getSolr().concurrentQuery(q.toString(), 0, 100000, TIMEOUT, 100,- YaCySchema.id.getSolrFieldName(),- YaCySchema.sku.getSolrFieldName(),- YaCySchema.failreason_t.getSolrFieldName(),- YaCySchema.failtype_s.getSolrFieldName(),- YaCySchema.inboundlinks_protocol_sxt.getSolrFieldName(),- YaCySchema.inboundlinks_urlstub_txt.getSolrFieldName(),- YaCySchema.outboundlinks_protocol_sxt.getSolrFieldName(),- YaCySchema.outboundlinks_urlstub_txt.getSolrFieldName(),- YaCySchema.clickdepth_i.getSolrFieldName()+ BlockingQueue<SolrDocument> docs = fulltext.getDefaultConnector().concurrentQuery(q.toString(), 0, 100000, TIMEOUT, 100,+ CollectionSchema.id.getSolrFieldName(),+ CollectionSchema.sku.getSolrFieldName(),+ CollectionSchema.failreason_t.getSolrFieldName(),+ CollectionSchema.failtype_s.getSolrFieldName(),+ CollectionSchema.inboundlinks_protocol_sxt.getSolrFieldName(),+ CollectionSchema.inboundlinks_urlstub_txt.getSolrFieldName(),+ CollectionSchema.outboundlinks_protocol_sxt.getSolrFieldName(),+ CollectionSchema.outboundlinks_urlstub_txt.getSolrFieldName(),+ CollectionSchema.clickdepth_i.getSolrFieldName());SolrDocument doc;Set<String> storedDocs = new HashSet<String>();@@ -266,14 +266,14 @@ public class HostBrowser {final List<byte[]> deleteIDs = new ArrayList<byte[]>();long timeout = System.currentTimeMillis() + TIMEOUT;while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {- String u = (String) doc.getFieldValue(YaCySchema.sku.getSolrFieldName());- String errortype = (String) doc.getFieldValue(YaCySchema.failtype_s.getSolrFieldName());+ String u = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());+ String errortype = (String) doc.getFieldValue(CollectionSchema.failtype_s.getSolrFieldName());FailType error = errortype == null ? null : FailType.valueOf(errortype);- Integer cd = (Integer) doc.getFieldValue(YaCySchema.clickdepth_i.getSolrFieldName());- if (cd != null && cd.intValue() >= 0) clickdepth.add(ASCII.getBytes((String) doc.getFieldValue(YaCySchema.id.getSolrFieldName())), cd.intValue());+ Integer cd = (Integer) doc.getFieldValue(CollectionSchema.clickdepth_i.getSolrFieldName());+ if (cd != null && cd.intValue() >= 0) clickdepth.add(ASCII.getBytes((String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName())), cd.intValue());if (u.startsWith(path)) {if (delete) {- deleteIDs.add(ASCII.getBytes((String) doc.getFieldValue(YaCySchema.id.getSolrFieldName())));+ deleteIDs.add(ASCII.getBytes((String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName())));} else {if (error == null) storedDocs.add(u); else if (admin) errorDocs.put(u, error);}diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.javaindex bbbb2b480..2fd724c99 100644--- a/htroot/IndexControlURLs_p.java+++ b/htroot/IndexControlURLs_p.java@@ -34,7 +34,6 @@ import java.util.Map;import net.yacy.cora.date.GenericFormatter;import net.yacy.cora.document.ASCII;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.yacy.CacheStrategy;import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.protocol.RequestHeader;@@ -49,6 +48,7 @@ import net.yacy.kelondro.logging.Log;import net.yacy.search.Switchboard;import net.yacy.search.index.Fulltext;import net.yacy.search.index.Segment;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -290,8 +290,8 @@ public class IndexControlURLs_p {int cnt = 0;try {final Fulltext metadata = segment.fulltext();- Map<String, ReversibleScoreMap<String>> scores = metadata.getSolr().getFacets(YaCySchema.httpstatus_i.getSolrFieldName() + ":200", count, YaCySchema.host_s.getSolrFieldName());- ReversibleScoreMap<String> stats = scores.get(YaCySchema.host_s.getSolrFieldName());+ Map<String, ReversibleScoreMap<String>> scores = metadata.getDefaultConnector().getFacets(CollectionSchema.httpstatus_i.getSolrFieldName() + ":200", count, CollectionSchema.host_s.getSolrFieldName());+ ReversibleScoreMap<String> stats = scores.get(CollectionSchema.host_s.getSolrFieldName());Iterator<String> statsiter = stats.keys(false);boolean dark = true;String hostname;diff --git a/htroot/IndexFederated_p.java b/htroot/IndexFederated_p.javaindex efd8d5332..124e9507b 100644--- a/htroot/IndexFederated_p.java+++ b/htroot/IndexFederated_p.java@@ -28,10 +28,10 @@ import org.apache.solr.common.SolrException;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.solr.connector.RemoteSolrConnector;-import net.yacy.cora.federate.solr.connector.ShardSelection;import net.yacy.cora.federate.solr.connector.ShardSolrConnector;import net.yacy.cora.federate.solr.connector.SolrConnector;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;+import net.yacy.cora.federate.solr.instance.RemoteInstance;+import net.yacy.cora.federate.solr.instance.ShardInstance;import net.yacy.cora.protocol.RequestHeader;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.OS;@@ -124,9 +124,8 @@ public class IndexFederated_p {final boolean usesolr = sb.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false) & solrurls.length() > 0;try {if (usesolr) {- ArrayList<SolrRemoteInstance> instances = ShardSolrConnector.getShardInstances(solrurls);- ShardSolrConnector solr = new ShardSolrConnector(instances, ShardSelection.Method.MODULO_HOST_MD5, true);- sb.index.fulltext().connectRemoteSolr(solr);+ ArrayList<RemoteInstance> instances = ShardSolrConnector.getShardInstances(solrurls, null, null);+ sb.index.fulltext().connectRemoteSolr(instances);} else {sb.index.fulltext().disconnectRemoteSolr();}@@ -148,13 +147,13 @@ public class IndexFederated_p {prop.put("table", 0);} else {prop.put("table", 1);- final SolrConnector solr = sb.index.fulltext().getRemoteSolr();+ final SolrConnector solr = sb.index.fulltext().getDefaultRemoteSolrConnector();final long[] size = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getSizeList() : new long[]{((RemoteSolrConnector) solr).getSize()};- final String[] urls = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getAdminInterfaceList() : new String[]{((SolrRemoteInstance) ((RemoteSolrConnector) solr).getInstance()).getAdminInterface()};+ final ArrayList<String> urls = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getAdminInterfaces() : ((ShardInstance) ((RemoteSolrConnector) solr).getInstance()).getAdminInterfaces();boolean dark = false;for (int i = 0; i < size.length; i++) {prop.put("table_list_" + i + "_dark", dark ? 1 : 0); dark = !dark;- prop.put("table_list_" + i + "_url", urls[i]);+ prop.put("table_list_" + i + "_url", urls.get(i));prop.put("table_list_" + i + "_size", size[i]);}prop.put("table_list", size.length);diff --git a/htroot/IndexSchema_p.html b/htroot/IndexSchema_p.htmlindex 2b063a073..81283a04c 100644--- a/htroot/IndexSchema_p.html+++ b/htroot/IndexSchema_p.html@@ -6,7 +6,7 @@</head><body id="IndexSchema_p"><div id="api">-<a href="/api/schema.xml">+<a href="/api/schema.xml?core=#[core]#"><img src="env/grafics/api.png" width="60" height="40" alt="API" /></a><span>The solr schema can also be retrieved as xml here. Click the API icon to see the xml. Just copy this xml to solr/conf/schema.xml to configure solr.</span></div>@@ -15,8 +15,18 @@<h2>Solr Schema Editor</h2><p>If you use a custom Solr schema you may enter a different field name in the column 'Custom Solr Field Name' of the YaCy default attribute name</p>+ <form action="IndexSchema_p.html" method="get" enctype="multipart/form-data" accept-charset="UTF-8">+ Select a Core:+ <select id="core" name="core" onchange='submit()'>+ #{cores}#+ <option value="#[name]#" #(selected)#::selected="selected"#(/selected)#>#[name]#</option>+ #{/cores}#+ </select>+ </form>+<form action="IndexSchema_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8"><fieldset>+ <input type="hidden" name="core" value="#[core]#" /><div><table class="sortable" border="0" cellpadding="2" cellspacing="1"><tr class="TableHeader" valign="bottom">diff --git a/htroot/IndexSchema_p.java b/htroot/IndexSchema_p.javaindex f47432d93..699c0f936 100644--- a/htroot/IndexSchema_p.java+++ b/htroot/IndexSchema_p.java@@ -21,11 +21,13 @@import java.io.IOException;import java.util.Iterator;-import net.yacy.cora.federate.solr.YaCySchema;-import net.yacy.cora.federate.yacy.ConfigurationSet;+import net.yacy.cora.federate.solr.SchemaConfiguration;+import net.yacy.cora.federate.solr.SchemaDeclaration;import net.yacy.cora.protocol.RequestHeader;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;+import net.yacy.search.schema.CollectionSchema;+import net.yacy.search.schema.WebgraphSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -36,10 +38,14 @@ public class IndexSchema_p {final serverObjects prop = new serverObjects();final Switchboard sb = (Switchboard) env;+ String schemaName = CollectionSchema.CORE_NAME;+ if (post != null) schemaName = post.get("core", schemaName);+ SchemaConfiguration cs = schemaName.equals(CollectionSchema.CORE_NAME) ? sb.index.fulltext().getDefaultConfiguration() : sb.index.fulltext().getWebgraphConfiguration();+if (post != null && post.containsKey("set")) {// read index schema table flags- final Iterator<ConfigurationSet.Entry> i = sb.index.fulltext().getSolrSchema().entryIterator();- ConfigurationSet.Entry entry;+ final Iterator<SchemaConfiguration.Entry> i = cs.entryIterator();+ SchemaConfiguration.Entry entry;boolean modified = false; // flag to remember changeswhile (i.hasNext()) {entry = i.next();@@ -61,7 +67,9 @@ public class IndexSchema_p {}if (modified) { // save settings to config file if modifiedtry {- sb.index.fulltext().getSolrSchema().commit();+ cs.commit();+ sb.index.fulltext().getDefaultConfiguration().commit();+ sb.index.fulltext().getWebgraphConfiguration().commit();modified = false;} catch (IOException ex) {}}@@ -74,15 +82,23 @@ public class IndexSchema_p {int c = 0;boolean dark = false;// use enum SolrField to keep defined order- for(YaCySchema field : YaCySchema.values()) {+ SchemaDeclaration[] cc = schemaName.equals(CollectionSchema.CORE_NAME) ? CollectionSchema.values() : WebgraphSchema.values();+ for(SchemaDeclaration field : cc) {prop.put("schema_" + c + "_dark", dark ? 1 : 0); dark = !dark;- prop.put("schema_" + c + "_checked", sb.index.fulltext().getSolrSchema().contains(field.name()) ? 1 : 0);+ prop.put("schema_" + c + "_checked", cs.contains(field.name()) ? 1 : 0);prop.putHTML("schema_" + c + "_key", field.name());prop.putHTML("schema_" + c + "_solrfieldname",field.name().equalsIgnoreCase(field.getSolrFieldName()) ? "" : field.getSolrFieldName());if (field.getComment() != null) prop.putHTML("schema_" + c + "_comment",field.getComment());c++;}prop.put("schema", c);++ prop.put("cores_" + 0 + "_name", CollectionSchema.CORE_NAME);+ prop.put("cores_" + 0 + "_selected", CollectionSchema.CORE_NAME.equals(schemaName) ? 1 : 0);+ prop.put("cores_" + 1 + "_name", WebgraphSchema.CORE_NAME);+ prop.put("cores_" + 1 + "_selected", WebgraphSchema.CORE_NAME.equals(schemaName) ? 1 : 0);+ prop.put("cores", 2);+ prop.put("core", schemaName);prop.put("lazy.checked", env.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, true) ? 1 : 0);diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.javaindex d7a51aa1e..e9e2b2ba0 100644--- a/htroot/PerformanceMemory_p.java+++ b/htroot/PerformanceMemory_p.java@@ -30,8 +30,7 @@ import java.util.ConcurrentModificationException;import java.util.Iterator;import java.util.Map;-import net.yacy.cora.federate.solr.YaCySchema;-import net.yacy.cora.federate.solr.connector.MirrorSolrConnector;+import net.yacy.cora.federate.solr.connector.CachedSolrConnector;import net.yacy.cora.protocol.Domains;import net.yacy.cora.protocol.RequestHeader;import net.yacy.kelondro.index.Cache;@@ -42,6 +41,7 @@ import net.yacy.kelondro.util.Formatter;import net.yacy.kelondro.util.MemoryControl;import net.yacy.search.Switchboard;import net.yacy.search.query.SearchEventCache;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -204,8 +204,8 @@ public class PerformanceMemory_p {prop.putNum("objectMissCacheTotalMem", totalmissmem / (1024d * 1024d));// other caching structures- final MirrorSolrConnector solr = (MirrorSolrConnector) Switchboard.getSwitchboard().index.fulltext().getSolr();- final MirrorSolrConnector.HitMissCache hitMissCache = solr.getHitMissCache(YaCySchema.id.getSolrFieldName());+ final CachedSolrConnector solr = (CachedSolrConnector) Switchboard.getSwitchboard().index.fulltext().getDefaultConnector();+ final CachedSolrConnector.HitMissCache hitMissCache = solr.getCache(CollectionSchema.id.getSolrFieldName());prop.putNum("solrcacheHit.size", solr.nameCacheHitSize());prop.putNum("solrcacheHit.Hit", hitMissCache.hitCache_Hit);prop.putNum("solrcacheHit.Miss", hitMissCache.hitCache_Miss);diff --git a/htroot/RankingSolr_p.java b/htroot/RankingSolr_p.javaindex 71247ad39..7aa2e48eb 100644--- a/htroot/RankingSolr_p.java+++ b/htroot/RankingSolr_p.java@@ -21,11 +21,11 @@import java.util.Map;import net.yacy.cora.federate.solr.Boost;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.protocol.RequestHeader;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;import net.yacy.search.query.SearchEventCache;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -58,7 +58,7 @@ public class RankingSolr_p {for (Map.Entry<String, String> entry: post.entrySet()) {if (entry.getKey().startsWith("boost")) {String fieldName = entry.getKey().substring(6);- YaCySchema field = YaCySchema.valueOf(fieldName);+ CollectionSchema field = CollectionSchema.valueOf(fieldName);if (field == null) continue;try {float boost = Float.parseFloat(entry.getValue());@@ -85,8 +85,8 @@ public class RankingSolr_p {prop.put("minTokenLen", Boost.RANKING.getMinTokenLen());prop.put("quantRate", Boost.RANKING.getQuantRate());int i = 0;- for (Map.Entry<YaCySchema, Float> entry: Boost.RANKING.entrySet()) {- YaCySchema field = entry.getKey();+ for (Map.Entry<CollectionSchema, Float> entry: Boost.RANKING.entrySet()) {+ CollectionSchema field = entry.getKey();float boost = entry.getValue();prop.put("boosts_" + i + "_field", field.getSolrFieldName());prop.put("boosts_" + i + "_boost", Float.toString(boost));diff --git a/htroot/api/schema.java b/htroot/api/schema.javaindex 74c774500..b8754dca5 100644--- a/htroot/api/schema.java+++ b/htroot/api/schema.java@@ -22,27 +22,33 @@* If not, see <http://www.gnu.org/licenses/>.*/-import net.yacy.cora.federate.solr.YaCySchema;+import net.yacy.cora.federate.solr.SchemaConfiguration;+import net.yacy.cora.federate.solr.SchemaDeclaration;import net.yacy.cora.protocol.HeaderFramework;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.protocol.ResponseHeader;import net.yacy.search.Switchboard;-import net.yacy.search.index.SolrConfiguration;+import net.yacy.search.schema.CollectionSchema;+import net.yacy.search.schema.WebgraphSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;import net.yacy.server.servletProperties;public class schema {- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {+ public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {// return variable that accumulates replacementsfinal servletProperties prop = new servletProperties();final Switchboard sb = (Switchboard) env;+ String schemaName = CollectionSchema.CORE_NAME;+ if (post != null) schemaName = post.get("core", schemaName);+// write schemaint c = 0;- SolrConfiguration solrSchema = sb.index.fulltext().getSolrSchema();- for (YaCySchema field : YaCySchema.values()) {+ SchemaConfiguration solrSchema = schemaName.equals(CollectionSchema.CORE_NAME) ? sb.index.fulltext().getDefaultConfiguration() : sb.index.fulltext().getWebgraphConfiguration();+ SchemaDeclaration[] cc = schemaName.equals(CollectionSchema.CORE_NAME) ? CollectionSchema.values() : WebgraphSchema.values();+ for (SchemaDeclaration field : cc) {if (solrSchema.contains(field.name())) {addField(prop, c, field);c++;@@ -51,16 +57,27 @@ public class schema {//if (solrScheme.contains(YaCySchema.author)) {addField(prop, c, YaCySchema.author_sxt);}prop.put("fields", c);- prop.put("copyFieldAuthor", solrSchema.contains(YaCySchema.author) ? 1 : 0);-- prop.put("solruniquekey",YaCySchema.id.getSolrFieldName());- prop.put("solrdefaultsearchfield",- solrSchema.contains(YaCySchema.text_t) ? YaCySchema.text_t.getSolrFieldName() :- solrSchema.contains(YaCySchema.fuzzy_signature_text_t) ? YaCySchema.fuzzy_signature_text_t.getSolrFieldName() :- solrSchema.contains(YaCySchema.h1_txt) ? YaCySchema.h1_txt.getSolrFieldName() :- YaCySchema.id.getSolrFieldName()- );-+ if (schemaName.equals(CollectionSchema.CORE_NAME)) {+ prop.put("copyFieldAuthor", solrSchema.contains(CollectionSchema.author) ? 1 : 0);++ prop.put("solruniquekey", CollectionSchema.id.getSolrFieldName());+ prop.put("solrdefaultsearchfield",+ solrSchema.contains(CollectionSchema.text_t) ? CollectionSchema.text_t.getSolrFieldName() :+ solrSchema.contains(CollectionSchema.fuzzy_signature_text_t) ? CollectionSchema.fuzzy_signature_text_t.getSolrFieldName() :+ solrSchema.contains(CollectionSchema.h1_txt) ? CollectionSchema.h1_txt.getSolrFieldName() :+ CollectionSchema.id.getSolrFieldName()+ );+ } else {+ prop.put("copyFieldAuthor", 0);++ prop.put("solruniquekey", WebgraphSchema.id.getSolrFieldName());+ prop.put("solrdefaultsearchfield",+ solrSchema.contains(WebgraphSchema.target_linktext_t) ? WebgraphSchema.target_linktext_t.getSolrFieldName() :+ solrSchema.contains(WebgraphSchema.target_name_t) ? WebgraphSchema.target_name_t.getSolrFieldName() :+ solrSchema.contains(WebgraphSchema.target_alt_t) ? WebgraphSchema.target_alt_t.getSolrFieldName() :+ WebgraphSchema.id.getSolrFieldName()+ );+ }// add CORS Access headerfinal ResponseHeader outgoingHeader = new ResponseHeader(200);@@ -71,7 +88,7 @@ public class schema {return prop;}- private static void addField(servletProperties prop, int c, YaCySchema field) {+ private static void addField(servletProperties prop, int c, SchemaDeclaration field) {prop.put("fields_" + c + "_solrname", field.getSolrFieldName());prop.put("fields_" + c + "_type", field.getType().printName());prop.put("fields_" + c + "_comment", field.getComment());diff --git a/htroot/gsa/searchresult.java b/htroot/gsa/searchresult.javaindex 0fbf7d684..78cb84ac5 100644--- a/htroot/gsa/searchresult.java+++ b/htroot/gsa/searchresult.java@@ -27,7 +27,6 @@ import java.util.Map;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.solr.Boost;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;import net.yacy.cora.federate.solr.responsewriter.GSAResponseWriter;import net.yacy.cora.protocol.HeaderFramework;@@ -39,6 +38,7 @@ import net.yacy.search.SwitchboardConstants;import net.yacy.search.query.AccessTracker;import net.yacy.search.query.QueryGoal;import net.yacy.search.query.SearchEvent;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -114,7 +114,7 @@ public class searchresult {// get a solr query stringQueryGoal qg = new QueryGoal(originalQuery, originalQuery);- StringBuilder solrQ = qg.solrQueryString(sb.index.fulltext().getSolrSchema());+ StringBuilder solrQ = qg.solrQueryString(sb.index.fulltext().getDefaultConfiguration());post.put("defType", "edismax");post.put(CommonParams.Q, solrQ.toString());post.put(CommonParams.ROWS, post.remove("num"));@@ -122,18 +122,18 @@ public class searchresult {post.put("bq", Boost.RANKING.getBoostQuery()); // a boost query that moves double content to the backpost.put("bf", Boost.RANKING.getBoostFunction()); // a boost function extensionpost.put(CommonParams.FL,- YaCySchema.content_type.getSolrFieldName() + ',' +- YaCySchema.id.getSolrFieldName() + ',' +- YaCySchema.sku.getSolrFieldName() + ',' +- YaCySchema.title.getSolrFieldName() + ',' +- YaCySchema.description.getSolrFieldName() + ',' +- YaCySchema.load_date_dt.getSolrFieldName() + ',' +- YaCySchema.last_modified.getSolrFieldName() + ',' +- YaCySchema.size_i.getSolrFieldName());+ CollectionSchema.content_type.getSolrFieldName() + ',' ++ CollectionSchema.id.getSolrFieldName() + ',' ++ CollectionSchema.sku.getSolrFieldName() + ',' ++ CollectionSchema.title.getSolrFieldName() + ',' ++ CollectionSchema.description.getSolrFieldName() + ',' ++ CollectionSchema.load_date_dt.getSolrFieldName() + ',' ++ CollectionSchema.last_modified.getSolrFieldName() + ',' ++ CollectionSchema.size_i.getSolrFieldName());post.put("hl", "true");post.put("hl.q", originalQuery);- post.put("hl.fl", YaCySchema.h1_txt.getSolrFieldName() + "," + YaCySchema.h2_txt.getSolrFieldName() + "," + YaCySchema.text_t.getSolrFieldName());- post.put("hl.alternateField", YaCySchema.description.getSolrFieldName());+ post.put("hl.fl", CollectionSchema.h1_txt.getSolrFieldName() + "," + CollectionSchema.h2_txt.getSolrFieldName() + "," + CollectionSchema.text_t.getSolrFieldName());+ post.put("hl.alternateField", CollectionSchema.description.getSolrFieldName());post.put("hl.simple.pre", "<b>");post.put("hl.simple.post", "</b>");post.put("hl.fragsize", Integer.toString(SearchEvent.SNIPPET_MAX_LENGTH));@@ -158,18 +158,18 @@ public class searchresult {}StringBuilder fq = new StringBuilder(20);if (sites.size() > 1) {- fq.append(YaCySchema.collection_sxt.getSolrFieldName()).append(':').append(sites.get(0));+ fq.append(CollectionSchema.collection_sxt.getSolrFieldName()).append(':').append(sites.get(0));for (int i = 1; i < sites.size(); i++) {- fq.append(" OR ").append(YaCySchema.collection_sxt.getSolrFieldName()).append(':').append(sites.get(i));+ fq.append(" OR ").append(CollectionSchema.collection_sxt.getSolrFieldName()).append(':').append(sites.get(i));}} else if (sites.size() == 1) {- fq.append(YaCySchema.collection_sxt.getSolrFieldName()).append(':').append(sites.get(0));+ fq.append(CollectionSchema.collection_sxt.getSolrFieldName()).append(':').append(sites.get(0));}post.put(CommonParams.FQ, fq.toString());}// get the embedded connector- EmbeddedSolrConnector connector = (EmbeddedSolrConnector) sb.index.fulltext().getLocalSolr();+ EmbeddedSolrConnector connector = sb.index.fulltext().getDefaultLocalSolrConnector();if (connector == null) return null;// do the solr requestdiff --git a/htroot/migrateurldb_p.java b/htroot/migrateurldb_p.javaindex 061a2edea..3a977aa0d 100644--- a/htroot/migrateurldb_p.java+++ b/htroot/migrateurldb_p.java@@ -8,7 +8,7 @@ import net.yacy.server.serverSwitch;public class migrateurldb_p {- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {+ public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {final serverObjects prop = new serverObjects();final Switchboard sb = (Switchboard) env;diff --git a/htroot/solr/select.java b/htroot/solr/select.javaindex 9d6fa285d..1ad96f2da 100644--- a/htroot/solr/select.java+++ b/htroot/solr/select.java@@ -181,7 +181,7 @@ public class select {}// get the embedded connector- EmbeddedSolrConnector connector = (EmbeddedSolrConnector) sb.index.fulltext().getLocalSolr();+ EmbeddedSolrConnector connector = sb.index.fulltext().getDefaultLocalSolrConnector();if (connector == null) return null;// do the solr request, generate facets if we use a special YaCy formatdiff --git a/htroot/yacyinteractive.java b/htroot/yacyinteractive.javaindex 8a050dcd2..4f9a35355 100644--- a/htroot/yacyinteractive.java+++ b/htroot/yacyinteractive.java@@ -34,7 +34,7 @@ import net.yacy.server.serverSwitch;public class yacyinteractive {- public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) {+ public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, serverObjects post, final serverSwitch env) {final Switchboard sb = (Switchboard) env;final serverObjects prop = new serverObjects();diff --git a/source/net/yacy/cora/federate/opensearch/OpenSearchConnector.java b/source/net/yacy/cora/federate/opensearch/OpenSearchConnector.javaindex 95c1cdc9b..c095bc0d8 100644--- a/source/net/yacy/cora/federate/opensearch/OpenSearchConnector.java+++ b/source/net/yacy/cora/federate/opensearch/OpenSearchConnector.java@@ -28,16 +28,17 @@ import java.util.HashSet;import java.util.Iterator;import java.util.Set;-import net.yacy.cora.federate.solr.YaCySchema;+import net.yacy.cora.federate.solr.SchemaConfiguration;+import net.yacy.cora.federate.solr.SchemaConfiguration.Entry;import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;-import net.yacy.cora.federate.yacy.ConfigurationSet;-import net.yacy.cora.federate.yacy.ConfigurationSet.Entry;import net.yacy.cora.util.SpaceExceededException;import net.yacy.document.parser.xml.opensearchdescriptionReader;import net.yacy.kelondro.blob.Tables;import net.yacy.kelondro.logging.Log;import net.yacy.search.Switchboard;import net.yacy.search.query.SearchEvent;+import net.yacy.search.schema.CollectionSchema;+import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;@@ -63,7 +64,7 @@ public class OpenSearchConnector {if (createworktable) { // read from config file and create worktablesb.tables.clear("opensearchsys");try {- ConfigurationSet cfg = new ConfigurationSet(confFile);+ SchemaConfiguration cfg = new SchemaConfiguration(confFile);// copy active opensearch systems to a work table (opensearchsys)Iterator<Entry> cfgentries = cfg.entryIterator();@@ -140,7 +141,7 @@ public class OpenSearchConnector {return false;}- ConfigurationSet conf = new ConfigurationSet(confFile);+ SchemaConfiguration conf = new SchemaConfiguration(confFile);if (name != null && !name.isEmpty()) {conf.add(name, null, active);Entry e = conf.get(name);@@ -174,21 +175,21 @@ public class OpenSearchConnector {if (sb == null) {return false;}- final EmbeddedSolrConnector connector = (EmbeddedSolrConnector) sb.index.fulltext().getLocalSolr();+ final EmbeddedSolrConnector connector = sb.index.fulltext().getDefaultLocalSolrConnector();// check if needed Solr fields are available (selected)if (connector == null) {Log.logSevere("OpenSearchConnector.Discover", "Error on connecting to embedded Solr index");return false;}- final boolean metafieldNOTavailable = sb.index.fulltext().getSolrSchema().containsDisabled(YaCySchema.outboundlinks_tag_txt.name());+ final boolean metafieldNOTavailable = sb.index.fulltext().getDefaultConfiguration().containsDisabled(CollectionSchema.outboundlinks_tag_txt.name());if (metafieldNOTavailable) {Log.logWarning("OpenSearchConnector.Discover", "Solr Schema field outboundlinks_tag_txt must be switched on");return false;}// the solr query- final String solrquerystr = YaCySchema.outboundlinks_tag_txt.getSolrFieldName() + ":\"rel=\\\"search\\\"\" OR "- + YaCySchema.inboundlinks_tag_txt.getSolrFieldName() + ":\"rel=\\\"search\\\"\"&fl="- + YaCySchema.sku.getSolrFieldName() + "," + YaCySchema.outboundlinks_tag_txt.getSolrFieldName() +"," + YaCySchema.inboundlinks_tag_txt.getSolrFieldName();+ final String solrquerystr = CollectionSchema.outboundlinks_tag_txt.getSolrFieldName() + ":\"rel=\\\"search\\\"\" OR "+ + CollectionSchema.inboundlinks_tag_txt.getSolrFieldName() + ":\"rel=\\\"search\\\"\"&fl="+ + CollectionSchema.sku.getSolrFieldName() + "," + CollectionSchema.outboundlinks_tag_txt.getSolrFieldName() +"," + CollectionSchema.inboundlinks_tag_txt.getSolrFieldName();final long numfound;try {SolrDocumentList docList = connector.query(solrquerystr, 0, 1);@@ -226,11 +227,11 @@ public class OpenSearchConnector {Iterator<SolrDocument> docidx = docList.iterator();while (docidx.hasNext()) {SolrDocument sdoc = docidx.next();- Collection<Object> tagtxtlist = sdoc.getFieldValues(YaCySchema.outboundlinks_tag_txt.getSolrFieldName());+ Collection<Object> tagtxtlist = sdoc.getFieldValues(CollectionSchema.outboundlinks_tag_txt.getSolrFieldName());if (tagtxtlist == null) {- tagtxtlist = sdoc.getFieldValues(YaCySchema.inboundlinks_tag_txt.getSolrFieldName());+ tagtxtlist = sdoc.getFieldValues(CollectionSchema.inboundlinks_tag_txt.getSolrFieldName());} else {- tagtxtlist.addAll(sdoc.getFieldValues(YaCySchema.inboundlinks_tag_txt.getSolrFieldName()));+ tagtxtlist.addAll(sdoc.getFieldValues(CollectionSchema.inboundlinks_tag_txt.getSolrFieldName()));}Iterator<Object> tagtxtidx = tagtxtlist.iterator();while (tagtxtidx.hasNext()) {diff --git a/source/net/yacy/cora/federate/solr/Boost.java b/source/net/yacy/cora/federate/solr/Boost.javaindex 495e6344e..3b6ee1fbf 100644--- a/source/net/yacy/cora/federate/solr/Boost.java+++ b/source/net/yacy/cora/federate/solr/Boost.java@@ -23,6 +23,7 @@ package net.yacy.cora.federate.solr;import java.util.LinkedHashMap;import net.yacy.cora.util.CommonPattern;+import net.yacy.search.schema.CollectionSchema;/*** The Boost class is the solr ranking definition file. It contains boost values in a Linked HashMap; the 'linked'-Version is used@@ -30,7 +31,7 @@ import net.yacy.cora.util.CommonPattern;* Because the order is influence by a double-check mechanismn the attributes to apply a document signature are also integrated* into this class.*/-public class Boost extends LinkedHashMap<YaCySchema, Float> {+public class Boost extends LinkedHashMap<CollectionSchema, Float> {private static final long serialVersionUID = 5248172257724571603L;@@ -47,17 +48,17 @@ public class Boost extends LinkedHashMap<YaCySchema, Float> {public void initDefaults() {this.clear();- put(YaCySchema.sku, 20.0f);- put(YaCySchema.url_paths_sxt, 20.0f);- put(YaCySchema.title, 15.0f);- put(YaCySchema.h1_txt, 11.0f);- put(YaCySchema.h2_txt, 10.0f);- put(YaCySchema.author, 8.0f);- put(YaCySchema.description, 5.0f);- put(YaCySchema.keywords, 2.0f);- put(YaCySchema.text_t, 1.0f);- put(YaCySchema.synonyms_sxt, 0.9f);- put(YaCySchema.references_i, 0.5f);+ put(CollectionSchema.sku, 20.0f);+ put(CollectionSchema.url_paths_sxt, 20.0f);+ put(CollectionSchema.title, 15.0f);+ put(CollectionSchema.h1_txt, 11.0f);+ put(CollectionSchema.h2_txt, 10.0f);+ put(CollectionSchema.author, 8.0f);+ put(CollectionSchema.description, 5.0f);+ put(CollectionSchema.keywords, 2.0f);+ put(CollectionSchema.text_t, 1.0f);+ put(CollectionSchema.synonyms_sxt, 0.9f);+ put(CollectionSchema.references_i, 0.5f);}/**@@ -82,7 +83,7 @@ public class Boost extends LinkedHashMap<YaCySchema, Float> {for (String boost: bf) {int p = boost.indexOf('^');if (p < 0) continue;- YaCySchema field = YaCySchema.valueOf(boost.substring(0, p));+ CollectionSchema field = CollectionSchema.valueOf(boost.substring(0, p));Float factor = Float.parseFloat(boost.substring(p + 1));this.put(field, factor);}@@ -109,7 +110,7 @@ public class Boost extends LinkedHashMap<YaCySchema, Float> {* @return*/public String getBoostQuery() {- return YaCySchema.fuzzy_signature_unique_b.getSolrFieldName() + ":true^100000.0f";+ return CollectionSchema.fuzzy_signature_unique_b.getSolrFieldName() + ":true^100000.0f";}/**diff --git a/source/net/yacy/cora/federate/yacy/ConfigurationSet.java b/source/net/yacy/cora/federate/solr/SchemaConfiguration.javasimilarity index 78%rename from source/net/yacy/cora/federate/yacy/ConfigurationSet.javarename to source/net/yacy/cora/federate/solr/SchemaConfiguration.javaindex 56248a51b..163683812 100644--- a/source/net/yacy/cora/federate/yacy/ConfigurationSet.java+++ b/source/net/yacy/cora/federate/solr/SchemaConfiguration.java@@ -1,5 +1,5 @@/**- * ConfigurationSet+ * SchemaConfiguration* Copyright 2011 by Michael Peter Christen, [email protected], Frankfurt a. M., Germany* First released 29.06.2011 at http://yacy.net*@@ -18,7 +18,7 @@* If not, see <http://www.gnu.org/licenses/>.*/-package net.yacy.cora.federate.yacy;+package net.yacy.cora.federate.solr;import java.io.BufferedReader;import java.io.BufferedWriter;@@ -27,13 +27,16 @@ import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.Serializable;+import java.util.Date;import java.util.Iterator;+import java.util.List;import java.util.Map;import java.util.TreeMap;import org.apache.log4j.Logger;+import org.apache.solr.common.SolrInputDocument;-import net.yacy.cora.federate.yacy.ConfigurationSet.Entry;+import net.yacy.cora.federate.solr.SchemaConfiguration.Entry;import net.yacy.cora.storage.Files;/**@@ -49,18 +52,20 @@ import net.yacy.cora.storage.Files;* - a line may contain a key only or a key=value pair* @author Michael Christen*/-public class ConfigurationSet extends TreeMap<String,Entry> implements Serializable {+public class SchemaConfiguration extends TreeMap<String,Entry> implements Serializable {private final static long serialVersionUID=-5961730809008841258L;- private final static Logger log = Logger.getLogger(ConfigurationSet.class);+ private final static Logger log = Logger.getLogger(SchemaConfiguration.class);private final File file;+ protected boolean lazy;- public ConfigurationSet() {+ public SchemaConfiguration() {this.file = null;+ this.lazy = false;}- public ConfigurationSet(final File file) {+ public SchemaConfiguration(final File file) {this.file = file;BufferedReader br = null;try {@@ -167,7 +172,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializareturn modified;}- public void fill(final ConfigurationSet other, final boolean defaultActivated) {+ public void fill(final SchemaConfiguration other, final boolean defaultActivated) {final Iterator<Entry> i = other.entryIterator();Entry e, enew = null;while (i.hasNext()) {@@ -176,7 +181,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializa// add as new entryenew = new Entry(e.key(),e.getValue(),defaultActivated && e.enabled());enew.setComment(e.getComment());- this.put (e.key(),enew);+ this.put(e.key(),enew);}if (enew != null) {try {@@ -187,6 +192,56 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializa}}+ public boolean contains(SchemaDeclaration field) {+ return this.contains(field.name());+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final String value) {+ assert !key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && !value.isEmpty()))) key.add(doc, value);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final Date value) {+ assert !key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && value.getTime() > 0))) key.add(doc, value);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final String[] value) {+ assert key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && value.length > 0))) key.add(doc, value);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final Integer[] value) {+ assert key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && value.length > 0))) key.add(doc, value);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final List<?> values) {+ assert key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || (values != null && !values.isEmpty()))) key.add(doc, values);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final int value) {+ assert !key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || value != 0)) key.add(doc, value);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final long value) {+ assert !key.isMultiValued();+ if ((isEmpty() || contains(key)) && (!this.lazy || value != 0)) key.add(doc, value);+ }++ public void add(final SolrInputDocument doc, final SchemaDeclaration key, final boolean value) {+ assert !key.isMultiValued();+ if (isEmpty() || contains(key)) key.add(doc, value);+ }++ public static Date getDate(SolrInputDocument doc, final SchemaDeclaration key) {+ Date x = (Date) doc.getFieldValue(key.getSolrFieldName());+ Date now = new Date();+ return (x == null) ? new Date(0) : x.after(now) ? now : x;+ }+/*** save the configuration back to the file* @throws IOException@@ -256,6 +311,10 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializawriter.close();}++++public Iterator<Entry> entryIterator() {return this.values().iterator();}@@ -320,7 +379,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializapublic static void main(final String[] args) {if (args.length == 0) return;final File f = new File (args[0]);- final ConfigurationSet cs = new ConfigurationSet(f);+ final SchemaConfiguration cs = new SchemaConfiguration(f);Iterator<Entry> i = cs.entryIterator();Entry k;System.out.println("\nall activated attributes:");diff --git a/source/net/yacy/cora/federate/solr/Schema.java b/source/net/yacy/cora/federate/solr/SchemaDeclaration.javasimilarity index 60%rename from source/net/yacy/cora/federate/solr/Schema.javarename to source/net/yacy/cora/federate/solr/SchemaDeclaration.javaindex 56b785473..626c2d517 100644--- a/source/net/yacy/cora/federate/solr/Schema.java+++ b/source/net/yacy/cora/federate/solr/SchemaDeclaration.java@@ -1,5 +1,5 @@/**- * SolrField+ * SchemaDeclaration* Copyright 2011 by Michael Peter Christen* First released 14.04.2011 at http://yacy.net*@@ -20,8 +20,12 @@package net.yacy.cora.federate.solr;+import java.util.Date;+import java.util.List;-public interface Schema {+import org.apache.solr.common.SolrInputDocument;++public interface SchemaDeclaration {/*** this shall be implemented as enum, thus shall have the name() method@@ -43,4 +47,26 @@ public interface Schema {public String getComment();+ public void setSolrFieldName(String name);++ public void add(final SolrInputDocument doc, final String value);++ public void add(final SolrInputDocument doc, final Date value);++ public void add(final SolrInputDocument doc, final int value);++ public void add(final SolrInputDocument doc, final long value);++ public void add(final SolrInputDocument doc, final String[] value);++ public void add(final SolrInputDocument doc, final Integer[] value);++ public void add(final SolrInputDocument doc, final List<?> value);++ public void add(final SolrInputDocument doc, final float value);++ public void add(final SolrInputDocument doc, final double value);++ public void add(final SolrInputDocument doc, final boolean value);+}\ No newline at end of filediff --git a/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.javaindex 5a12ebbc6..72a87c21a 100644--- a/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java@@ -31,10 +31,10 @@ import java.util.concurrent.LinkedBlockingQueue;import java.util.concurrent.TimeUnit;import net.yacy.cora.document.UTF8;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.sorting.ClusteredScoreMap;import net.yacy.cora.sorting.ReversibleScoreMap;import net.yacy.cora.util.LookAheadIterator;+import net.yacy.search.schema.CollectionSchema;import org.apache.log4j.Logger;import org.apache.solr.client.solrj.SolrQuery;@@ -56,14 +56,14 @@ public abstract class AbstractSolrConnector implements SolrConnector {public final static SolrQuery catchallQuery = new SolrQuery();static {catchallQuery.setQuery("*:*");- catchallQuery.setFields(YaCySchema.id.getSolrFieldName());+ catchallQuery.setFields(CollectionSchema.id.getSolrFieldName());catchallQuery.setRows(1);catchallQuery.setStart(0);}public final static SolrQuery catchSuccessQuery = new SolrQuery();static {- catchSuccessQuery.setQuery("-" + YaCySchema.failreason_t.getSolrFieldName() + ":[* TO *]");- catchSuccessQuery.setFields(YaCySchema.id.getSolrFieldName());+ catchSuccessQuery.setQuery("-" + CollectionSchema.failreason_t.getSolrFieldName() + ":[* TO *]");+ catchSuccessQuery.setFields(CollectionSchema.id.getSolrFieldName());catchSuccessQuery.setRows(1);catchSuccessQuery.setStart(0);}@@ -138,9 +138,9 @@ public abstract class AbstractSolrConnector implements SolrConnector {int o = offset;while (System.currentTimeMillis() < endtime) {try {- SolrDocumentList sdl = query(querystring, o, pagesize, YaCySchema.id.getSolrFieldName());+ SolrDocumentList sdl = query(querystring, o, pagesize, CollectionSchema.id.getSolrFieldName());for (SolrDocument d: sdl) {- try {queue.put((String) d.getFieldValue(YaCySchema.id.getSolrFieldName()));} catch (InterruptedException e) {break;}+ try {queue.put((String) d.getFieldValue(CollectionSchema.id.getSolrFieldName()));} catch (InterruptedException e) {break;}}if (sdl.size() < pagesize) break;o += pagesize;@@ -213,7 +213,7 @@ public abstract class AbstractSolrConnector implements SolrConnector {params.setRows(0);params.setStart(0);params.setFacet(false);- params.setFields(YaCySchema.id.getSolrFieldName());+ params.setFields(CollectionSchema.id.getSolrFieldName());// query the serverQueryResponse rsp = query(params);diff --git a/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.javanew file mode 100644index 000000000..01bc4d8ca--- /dev/null+++ b/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.java@@ -0,0 +1,329 @@+/**+ * CachedSolrConnector+ * Copyright 2013 by Michael Peter Christen+ * First released 18.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.cora.federate.solr.connector;++import java.io.IOException;+import java.util.List;+import java.util.Map;+import java.util.concurrent.ConcurrentHashMap;++import net.yacy.cora.sorting.ReversibleScoreMap;+import net.yacy.cora.storage.ARC;+import net.yacy.cora.storage.ConcurrentARC;+import net.yacy.kelondro.util.MemoryControl;+import net.yacy.search.schema.CollectionSchema;++import org.apache.solr.client.solrj.response.QueryResponse;+import org.apache.solr.client.solrj.util.ClientUtils;+import org.apache.solr.common.SolrDocument;+import org.apache.solr.common.SolrDocumentList;+import org.apache.solr.common.SolrException;+import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.common.params.ModifiableSolrParams;++public class CachedSolrConnector extends AbstractSolrConnector implements SolrConnector {++ private final static Object EXIST = new Object();++ private SolrConnector solr;+ private int hitCacheMax, missCacheMax, partitions;+ private final Map<String, HitMissCache> hitMissCache;+ private final ARC<String, SolrDocument> documentCache;+ public long documentCache_Hit = 0, documentCache_Miss = 0, documentCache_Insert = 0; // for statistics only; do not write+++ public static class HitMissCache {++ public final ARC<String, Object> hitCache, missCache;+ public long hitCache_Hit = 0, hitCache_Miss = 0, hitCache_Insert = 0; // for statistics only; do not write+ public long missCache_Hit = 0, missCache_Miss = 0, missCache_Insert = 0; // for statistics only; do not write++ public HitMissCache(int hitCacheMax, int missCacheMax, int partitions) {+ this.hitCache = new ConcurrentARC<String, Object>(hitCacheMax, partitions);+ this.missCache = new ConcurrentARC<String, Object>(missCacheMax, partitions);+ }++ public void clearCache() {+ this.hitCache.clear();+ this.missCache.clear();+ }+ }++ public CachedSolrConnector(SolrConnector c, int hitCacheMax, int missCacheMax, int docCacheMax) {+ this.solr = c;+ this.hitCacheMax = hitCacheMax;+ this.missCacheMax = missCacheMax;+ this.partitions = Runtime.getRuntime().availableProcessors() * 2;+ this.hitMissCache = new ConcurrentHashMap<String, HitMissCache>();+ this.documentCache = new ConcurrentARC<String, SolrDocument>(docCacheMax, this.partitions);+ }+++ public HitMissCache getCache(String field) {+ HitMissCache c = this.hitMissCache.get(field);+ if (c == null) {+ c = new HitMissCache(this.hitCacheMax, this.missCacheMax, this.partitions);+ this.hitMissCache.put(field, c);+ }+ return c;+ }++ public void clearCache() {+ for (HitMissCache c: hitMissCache.values()) c.clearCache();+ this.documentCache.clear();+ }++ @Override+ public synchronized void close() {+ if (this.solr != null) this.solr.close();+ this.solr = null;+ this.clearCache();+ }++ /**+ * delete everything in the solr index+ * @throws IOException+ */+ @Override+ public void clear() throws IOException {+ this.clearCache();+ if (this.solr != null) this.solr.clear();+ }++ /**+ * delete an entry from solr+ * @param id the url hash of the entry+ * @throws IOException+ */+ @Override+ public void delete(final String id) throws IOException {+ this.documentCache.remove(id);+ HitMissCache c = getCache("id");+ c.hitCache.remove(id);+ c.missCache.put(id, EXIST);+ c.missCache_Insert++;+ if (this.solr != null) this.solr.delete(id);+ }++ /**+ * delete a set of entries from solr; entries are identified by their url hash+ * @param ids a list of url hashes+ * @throws IOException+ */+ @Override+ public void delete(final List<String> ids) throws IOException {+ for (String id: ids) {+ this.documentCache.remove(id);+ HitMissCache c = getCache("id");+ c.hitCache.remove(id);+ c.missCache.put(id, EXIST);+ c.missCache_Insert++;+ }+ if (this.solr != null) this.solr.delete(ids);+ }++ @Override+ public void deleteByQuery(final String querystring) throws IOException {+ this.clearCache();+ this.solr.deleteByQuery(querystring);+ }++ @Override+ public boolean exists(final String fieldName, final String key) throws IOException {+ HitMissCache c = getCache(fieldName);+ if (c.hitCache.containsKey(key)) {+ c.hitCache_Hit++;+ return true;+ }+ c.hitCache_Miss++;+ if (this.documentCache.containsKey(key)) {+ this.documentCache_Hit++;+ return true;+ }+ this.documentCache_Miss++;+ if (c.missCache.containsKey(key)) {+ c.missCache_Hit++;+ return false;+ }+ c.missCache_Miss++;+ if (solr != null && solr.exists(fieldName, key)) {+ c.missCache.remove(key);+ c.hitCache.put(key, EXIST);+ c.hitCache_Insert++;+ return true;+ }+ c.missCache.put(key, EXIST);+ c.missCache_Insert++;+ return false;+ }++ @Override+ public SolrDocument getById(final String key, final String ... fields) throws IOException {+ SolrDocument doc = fields.length == 0 ? this.documentCache.get(key) : null;+ if (doc != null) {+ this.documentCache_Hit++;+ return doc;+ }+ documentCache_Miss++;+ HitMissCache c = this.getCache(CollectionSchema.id.getSolrFieldName());+ if (c.missCache.containsKey(key)) {+ c.missCache_Hit++;+ return null;+ }+ c.missCache_Miss++;+ if (solr != null && ((doc = solr.getById(key, fields)) != null)) {+ addToCache(doc, fields.length == 0);+ return doc;+ }+ // check if there is a autocommit problem+ if (c.hitCache.containsKey(key)) {+ // the document should be there, therefore make a commit and check again+ if (solr != null && ((doc = solr.getById(key, fields)) != null)) {+ addToCache(doc, fields.length == 0);+ }+ }+ c.missCache.put(key, EXIST);+ c.missCache_Insert++;+ return null;+ }++ /**+ * add a Solr document+ * @param solrdoc+ * @throws IOException+ */+ @Override+ public void add(final SolrInputDocument solrdoc) throws IOException {+ String id = (String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName());+ assert id != null;+ if (id == null) return;+ SolrDocument doc = ClientUtils.toSolrDocument(solrdoc);+ addToCache(doc, true);+ this.documentCache.put(id, doc);+ this.documentCache_Insert++;+ if (this.solr != null) this.solr.add(solrdoc);+ }++ /**+ * get a query result from solr+ * to get all results set the query String to "*:*"+ * @param querystring+ * @throws IOException+ */+ @Override+ public SolrDocumentList query(final String querystring, final int offset, final int count, final String ... fields) throws IOException {+ if (offset == 0 && count == 1 && querystring.startsWith("id:")) {+ final SolrDocumentList list = new SolrDocumentList();+ SolrDocument doc = getById(querystring.charAt(3) == '"' ? querystring.substring(4, querystring.length() - 1) : querystring.substring(3), fields);+ list.add(doc);+ // no addToCache(list) here because that was already handlet in get();+ return list;+ }+ if (this.solr != null) {+ SolrDocumentList list = this.solr.query(querystring, offset, count, fields);+ addToCache(list, fields.length == 0);+ return list;+ }++ // combine both lists+ SolrDocumentList list;+ list = this.solr.query(querystring, offset, count, fields);++ // add caching+ addToCache(list, fields.length == 0);+ return list;+ }++ @Override+ public QueryResponse query(ModifiableSolrParams query) throws IOException, SolrException {+ QueryResponse list = this.solr.query(query);+ return list;+ }++ @Override+ public long getQueryCount(final String querystring) throws IOException {+ return this.solr.getQueryCount(querystring);+ }++ @Override+ public Map<String, ReversibleScoreMap<String>> getFacets(final String query, final int maxresults, final String ... fields) throws IOException {+ return this.solr.getFacets(query, maxresults, fields);+ }++ private void addToCache(SolrDocumentList list, boolean doccache) {+ if (MemoryControl.shortStatus()) clearCache();+ for (final SolrDocument solrdoc: list) {+ addToCache(solrdoc, doccache);+ }+ }++ private void addToCache(SolrDocument doc, boolean doccach) {+ for (Map.Entry<String, HitMissCache> e: this.hitMissCache.entrySet()) {+ Object keyo = doc.getFieldValue(e.getKey());+ String key = null;+ if (keyo instanceof String) key = (String) keyo;+ if (keyo instanceof Integer) key = ((Integer) keyo).toString();+ if (keyo instanceof Long) key = ((Long) keyo).toString();+ if (key != null) {+ HitMissCache c = e.getValue();+ c.missCache.remove(key);+ c.hitCache.put(key, EXIST);+ c.hitCache_Insert++;+ }+ }+ if (doccach) {+ this.documentCache.put((String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName()), doc);+ this.documentCache_Insert++;+ }+ }+++ @Override+ public long getSize() {+ long s = this.solr.getSize();+ HitMissCache c = getCache("id");+ return Math.max(this.documentCache.size(), Math.max(c.hitCache.size(), s));+ }++ public int nameCacheHitSize() {+ HitMissCache c = getCache("id");+ return c.hitCache.size();+ }++ public int nameCacheMissSize() {+ HitMissCache c = getCache("id");+ return c.missCache.size();+ }++ public int nameCacheDocumentSize() {+ return this.documentCache.size();+ }++ @Override+ public void commit(boolean softCommit) {+ this.solr.commit(softCommit);+ }++ @Override+ public void optimize(int maxSegments) {+ this.solr.optimize(maxSegments);+ }+}\ No newline at end of filediff --git a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.javaindex db82a18ed..ffa6f19ae 100644--- a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java@@ -24,7 +24,7 @@ package net.yacy.cora.federate.solr.connector;import java.io.IOException;import java.util.List;-import net.yacy.cora.federate.solr.instance.SolrEmbeddedInstance;+import net.yacy.cora.federate.solr.instance.EmbeddedInstance;import net.yacy.cora.federate.solr.instance.SolrInstance;import net.yacy.kelondro.logging.Log;@@ -57,10 +57,10 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCopublic static final String CONTEXT = "/solr";private final SearchHandler requestHandler;- private final SolrEmbeddedInstance instance;+ private final EmbeddedInstance instance;private SolrCore core;- public EmbeddedSolrConnector(SolrEmbeddedInstance instance) {+ public EmbeddedSolrConnector(EmbeddedInstance instance) {super();this.instance = instance;this.core = this.instance.getDefaultCore();@@ -70,7 +70,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCosuper.init(this.instance.getDefaultServer());}- public EmbeddedSolrConnector(SolrEmbeddedInstance instance, String coreName) {+ public EmbeddedSolrConnector(EmbeddedInstance instance, String coreName) {super();this.instance = instance;this.core = this.instance.getCore(coreName);diff --git a/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.javaindex cfa4d3bb1..c9dd8268f 100644--- a/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java@@ -1,7 +1,7 @@/**- * DoubleChardingConnector- * Copyright 2012 by Michael Peter Christen- * First released 23.07.2012 at http://yacy.net+ * MirrorSolrConnector+ * Copyright 2013 by Michael Peter Christen+ * First released 18.02.2012 at http://yacy.net** This library is free software; you can redistribute it and/or* modify it under the terms of the GNU Lesser General Public@@ -21,19 +21,15 @@package net.yacy.cora.federate.solr.connector;import java.io.IOException;-import java.util.ArrayList;+import java.util.HashMap;import java.util.List;import java.util.Map;-import java.util.concurrent.ConcurrentHashMap;+import java.util.concurrent.atomic.AtomicLong;-import net.yacy.cora.federate.solr.YaCySchema;-import net.yacy.cora.federate.solr.instance.SolrInstance;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;-import net.yacy.cora.storage.ARC;-import net.yacy.cora.storage.ConcurrentARC;+import net.yacy.cora.sorting.ReversibleScoreMap;+import net.yacy.search.schema.CollectionSchema;import org.apache.solr.client.solrj.response.QueryResponse;-import org.apache.solr.client.solrj.util.ClientUtils;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.SolrException;@@ -41,86 +37,26 @@ import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;-/**- * Implementation of a mirrored solr connector.- * Two Solr servers can be attached to serve as storage and search locations.- * When doing a retrieval only the first Solr is requested, if it does not answer or has no result, the second is used.- * When data is stored or deleted this applies to both attached solr.- * It is also possible to attach only one of the solr instances.- * Because it is not possible to set a cache in front of this class (the single connect methods would need to be passed through the cache class),- * this class also contains an object and hit/miss cache.- */public class MirrorSolrConnector extends AbstractSolrConnector implements SolrConnector {- private final static Object EXIST = new Object();-- private EmbeddedSolrConnector solr0;- private ShardSolrConnector solr1;- private int hitCacheMax, missCacheMax, partitions;- private final Map<String, HitMissCache> hitMissCache;- private final Map<String, ARC<String, Object>> fieldCache; // a map from a field name to a id-key/value object cache- private final ARC<String, SolrDocument> documentCache;- public long documentCache_Hit = 0, documentCache_Miss = 0, documentCache_Insert = 0; // for statistics only; do not write--- public static class HitMissCache {-- public final ARC<String, Object> hitCache, missCache;- public long hitCache_Hit = 0, hitCache_Miss = 0, hitCache_Insert = 0; // for statistics only; do not write- public long missCache_Hit = 0, missCache_Miss = 0, missCache_Insert = 0; // for statistics only; do not write-- public HitMissCache(int hitCacheMax, int missCacheMax, int partitions) {- this.hitCache = new ConcurrentARC<String, Object>(hitCacheMax, partitions);- this.missCache = new ConcurrentARC<String, Object>(missCacheMax, partitions);- }-- public void clearCache() {- this.hitCache.clear();- this.missCache.clear();- }- }+ // the twin solrs+ private SolrConnector solr0, solr1;- public MirrorSolrConnector(int hitCacheMax, int missCacheMax, int docCacheMax) {+ public MirrorSolrConnector() {this.solr0 = null;this.solr1 = null;- this.hitCacheMax = hitCacheMax;- this.missCacheMax = missCacheMax;- this.partitions = Runtime.getRuntime().availableProcessors() * 2;- this.hitMissCache = new ConcurrentHashMap<String, HitMissCache>();- this.fieldCache = new ConcurrentHashMap<String, ARC<String, Object>>();- this.documentCache = new ConcurrentARC<String, SolrDocument>(docCacheMax, this.partitions);- }-- public HitMissCache getHitMissCache(String field) {- HitMissCache c = this.hitMissCache.get(field);- if (c == null) {- c = new HitMissCache(this.hitCacheMax, this.missCacheMax, this.partitions);- this.hitMissCache.put(field, c);- }- return c;}- public ARC<String, Object> getFieldCache(String field) {- ARC<String, Object> c = this.fieldCache.get(field);- if (c == null) {- c = new ConcurrentARC<String, Object>(this.hitCacheMax, this.partitions);- this.fieldCache.put(field, c);- }- return c;- }-- /**- * the usage of getInstance is not possible here, use getSolr0().getInstance() instead- */- public SolrInstance getInstance() {- throw new UnsupportedOperationException();+ public MirrorSolrConnector(SolrConnector solr0, SolrConnector solr1) {+ this.solr0 = solr0;+ this.solr1 = solr1;}public boolean isConnected0() {return this.solr0 != null;}- public void connect0(EmbeddedSolrConnector c) {+ public void connect0(SolrConnector c) {this.solr0 = c;}@@ -130,9 +66,7 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCopublic void disconnect0() {if (this.solr0 == null) return;- SolrInstance instance = this.solr0.getInstance();this.solr0.close();- instance.close();this.solr0 = null;}@@ -140,7 +74,7 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCoreturn this.solr1 != null;}- public void connect1(ShardSolrConnector c) {+ public void connect1(SolrConnector c) {this.solr1 = c;}@@ -150,27 +84,17 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCopublic void disconnect1() {if (this.solr1 == null) return;- // we cannot get the instance here because that is not applicablethis.solr1.close();this.solr1 = null;}- public void clearCache() {- for (HitMissCache c: this.hitMissCache.values()) c.clearCache();- for (ARC<String, Object> c: this.fieldCache.values()) c.clear();- this.documentCache.clear();- }-@Override- public void commit(boolean softCommit) {+ public void commit(final boolean softCommit) {if (this.solr0 != null) this.solr0.commit(softCommit);if (this.solr1 != null) this.solr1.commit(softCommit);}- /**- * force an explicit merge of segments- * @param maxSegments the maximum number of segments. Set to 1 for maximum optimization- */+ @Overridepublic void optimize(int maxSegments) {if (this.solr0 != null) this.solr0.optimize(maxSegments);if (this.solr1 != null) this.solr1.optimize(maxSegments);@@ -178,34 +102,8 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo@Overridepublic synchronized void close() {- if (this.solr0 != null) {- SolrInstance instance = this.solr0.getInstance();- this.solr0.close();- instance.close();- }- if (this.solr1 != null) {- ArrayList<SolrRemoteInstance> instances = this.solr1.getInstances();- this.solr1.close();- for (SolrRemoteInstance instance: instances) instance.close();- }- }-- /**- * delete everything in the local solr index- * @throws IOException- */- public void clear0() throws IOException {- this.clearCache();- if (this.solr0 != null) this.solr0.clear();- }-- /**- * delete everything in the remote solr index- * @throws IOException- */- public void clear1() throws IOException {- this.clearCache();- if (this.solr1 != null) this.solr1.clear();+ if (this.solr0 != null) this.solr0.close();+ if (this.solr1 != null) this.solr1.close();}/**@@ -214,7 +112,6 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo*/@Overridepublic void clear() throws IOException {- this.clearCache();if (this.solr0 != null) this.solr0.clear();if (this.solr1 != null) this.solr1.clear();}@@ -226,11 +123,6 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo*/@Overridepublic void delete(final String id) throws IOException {- this.documentCache.remove(id);- HitMissCache c = getHitMissCache("id");- c.hitCache.remove(id);- c.missCache.put(id, EXIST);- c.missCache_Insert++;if (this.solr0 != null) this.solr0.delete(id);if (this.solr1 != null) this.solr1.delete(id);}@@ -242,13 +134,6 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo*/@Overridepublic void delete(final List<String> ids) throws IOException {- for (String id: ids) {- this.documentCache.remove(id);- HitMissCache c = getHitMissCache("id");- c.hitCache.remove(id);- c.missCache.put(id, EXIST);- c.missCache_Insert++;- }if (this.solr0 != null) this.solr0.delete(ids);if (this.solr1 != null) this.solr1.delete(ids);}@@ -257,83 +142,22 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCopublic void deleteByQuery(final String querystring) throws IOException {if (this.solr0 != null) this.solr0.deleteByQuery(querystring);if (this.solr1 != null) this.solr1.deleteByQuery(querystring);- this.clearCache();}@Overridepublic boolean exists(final String fieldName, final String key) throws IOException {- HitMissCache c = getHitMissCache(fieldName);- if (c.hitCache.containsKey(key)) {- c.hitCache_Hit++;- return true;- }- c.hitCache_Miss++;- if (this.documentCache.containsKey(key)) {- this.documentCache_Hit++;- return true;- }- this.documentCache_Miss++;- if (c.missCache.containsKey(key)) {- c.missCache_Hit++;- return false;- }- c.missCache_Miss++;if ((solr0 != null && solr0.exists(fieldName, key)) || (solr1 != null && solr1.exists(fieldName, key))) {- c.missCache.remove(key);- c.hitCache.put(key, EXIST);- c.hitCache_Insert++;return true;}- c.missCache.put(key, EXIST);- c.missCache_Insert++;return false;}-- @Override- public Object getFieldById(final String key, final String field) throws IOException {- // try to get this from this cache- ARC<String, Object> c = getFieldCache(field);- Object o = c.get(key);- if (o != null) return o;-- // load the document- o = super.getFieldById(key, field);-- // use result to fill the cache- if (o == null) return null;- c.put(key, o);- return o;- }@Overridepublic SolrDocument getById(final String key, final String ... fields) throws IOException {- SolrDocument doc = this.documentCache.get(key);- if (doc != null) {- this.documentCache_Hit++;- return doc;- }- documentCache_Miss++;- HitMissCache c = this.getHitMissCache(YaCySchema.id.getSolrFieldName());- if (c.missCache.containsKey(key)) {- c.missCache_Hit++;- return null;- }- c.missCache_Miss++;+ SolrDocument doc;if ((solr0 != null && ((doc = solr0.getById(key, fields)) != null)) || (solr1 != null && ((doc = solr1.getById(key, fields)) != null))) {- addToCache(doc, fields.length == 0);return doc;}- // check if there is a autocommit problem- if (c.hitCache.containsKey(key)) {- // the document should be there, therefore make a commit and check again- this.commit(true);- if ((solr0 != null && ((doc = solr0.getById(key, fields)) != null)) || (solr1 != null && ((doc = solr1.getById(key, fields)) != null))) {- addToCache(doc, fields.length == 0);- return doc;- }- }- c.missCache.put(key, EXIST);- c.missCache_Insert++;return null;}@@ -344,17 +168,60 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo*/@Overridepublic void add(final SolrInputDocument solrdoc) throws IOException {- String id = (String) solrdoc.getFieldValue(YaCySchema.id.getSolrFieldName());+ String id = (String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName());assert id != null;if (id == null) return;- SolrDocument doc = ClientUtils.toSolrDocument(solrdoc);- addToCache(doc, true);- this.documentCache.put(id, doc);- this.documentCache_Insert++;if (this.solr0 != null) this.solr0.add(solrdoc);if (this.solr1 != null) this.solr1.add(solrdoc);}+ /**+ * get a query result from solr+ * to get all results set the query String to "*:*"+ * @param querystring+ * @throws IOException+ */+ @Override+ public SolrDocumentList query(final String querystring, final int offset, final int count, final String ... fields) throws IOException {+ if (this.solr0 == null && this.solr1 == null) return new SolrDocumentList();+ if (offset == 0 && count == 1 && querystring.startsWith("id:")) {+ final SolrDocumentList list = new SolrDocumentList();+ SolrDocument doc = getById(querystring.charAt(3) == '"' ? querystring.substring(4, querystring.length() - 1) : querystring.substring(3), fields);+ list.add(doc);+ // no addToCache(list) here because that was already handlet in get();+ return list;+ }+ if (this.solr0 != null && this.solr1 == null) {+ SolrDocumentList list = this.solr0.query(querystring, offset, count, fields);+ return list;+ }+ if (this.solr1 != null && this.solr0 == null) {+ SolrDocumentList list = this.solr1.query(querystring, offset, count, fields);+ return list;+ }++ // combine both lists+ SolrDocumentList l;+ l = this.solr0.query(querystring, offset, count, fields);+ if (l.size() >= count) return l;++ // at this point we need to know how many results are in solr0+ // compute this with a very bad hack; replace with better method later+ int size0 = 0;+ { //bad hack - TODO: replace+ SolrDocumentList lHack = this.solr0.query(querystring, 0, Integer.MAX_VALUE, fields);+ size0 = lHack.size();+ }++ // now use the size of the first query to do a second query+ final SolrDocumentList list = new SolrDocumentList();+ for (final SolrDocument d: l) list.add(d);+ l = this.solr1.query(querystring, offset + l.size() - size0, count - l.size(), fields);+ for (final SolrDocument d: l) list.add(d);++ return list;+ }+@Overridepublic QueryResponse query(ModifiableSolrParams query) throws IOException, SolrException {Integer count0 = query.getInt(CommonParams.ROWS);@@ -398,57 +265,68 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo// TODO: combine bothreturn rsp1;}-- private void addToCache(SolrDocument doc, boolean doccach) {- for (Map.Entry<String, HitMissCache> e: this.hitMissCache.entrySet()) {- Object keyo = doc.getFieldValue(e.getKey());- if (keyo == null) continue;- String key = null;- if (keyo instanceof String) key = (String) keyo;- if (keyo instanceof Integer) key = ((Integer) keyo).toString();- if (keyo instanceof Long) key = ((Long) keyo).toString();- if (key != null) {- HitMissCache c = e.getValue();- c.missCache.remove(key);- c.hitCache.put(key, EXIST);- c.hitCache_Insert++;- }++ @Override+ public long getQueryCount(final String querystring) throws IOException {+ if (this.solr0 == null && this.solr1 == null) return 0;+ if (this.solr0 != null && this.solr1 == null) {+ return this.solr0.getQueryCount(querystring);}-- String id = (String) doc.getFieldValue(YaCySchema.id.getSolrFieldName());- if (id != null) {- for (Map.Entry<String, ARC<String, Object>> e: this.fieldCache.entrySet()) {- Object keyo = doc.getFieldValue(e.getKey());- if (keyo != null) e.getValue().put(id, keyo);+ if (this.solr1 != null && this.solr0 == null) {+ return this.solr1.getQueryCount(querystring);}+ final AtomicLong count = new AtomicLong(0);+ Thread t0 = new Thread() {+ @Override+ public void run() {+ try {+ count.addAndGet(MirrorSolrConnector.this.solr0.getQueryCount(querystring));+ } catch (IOException e) {}+ }+ };+ t0.start();+ Thread t1 = new Thread() {+ @Override+ public void run() {+ try {+ count.addAndGet(MirrorSolrConnector.this.solr1.getQueryCount(querystring));+ } catch (IOException e) {}+ }+ };+ t1.start();+ try {t0.join();} catch (InterruptedException e) {}+ try {t1.join();} catch (InterruptedException e) {}+ return count.get();+ }- if (doccach) {- this.documentCache.put(id, doc);- this.documentCache_Insert++;+ @Override+ public Map<String, ReversibleScoreMap<String>> getFacets(final String query, final int maxresults, final String ... fields) throws IOException {+ if (this.solr0 == null && this.solr1 == null) return new HashMap<String, ReversibleScoreMap<String>>(0);+ if (this.solr0 != null && this.solr1 == null) {+ return this.solr0.getFacets(query, maxresults, fields);+ }+ if (this.solr1 != null && this.solr0 == null) {+ return this.solr1.getFacets(query, maxresults, fields);}+ Map<String, ReversibleScoreMap<String>> facets0 = this.solr0.getFacets(query, maxresults, fields);+ Map<String, ReversibleScoreMap<String>> facets1 = this.solr1.getFacets(query, maxresults, fields);+ for (Map.Entry<String, ReversibleScoreMap<String>> facet0: facets0.entrySet()) {+ ReversibleScoreMap<String> facet1 = facets1.remove(facet0.getKey());+ if (facet1 == null) continue;+ for (String key: facet1) facet0.getValue().inc(key, facet1.get(key));}+ for (Map.Entry<String, ReversibleScoreMap<String>> facet1: facets1.entrySet()) {+ facets0.put(facet1.getKey(), facet1.getValue());+ }+ return facets0;}-+@Overridepublic long getSize() {long s = 0;if (this.solr0 != null) s += this.solr0.getSize();if (this.solr1 != null) s += this.solr1.getSize();- HitMissCache c = getHitMissCache("id");- return Math.max(this.documentCache.size(), Math.max(c.hitCache.size(), s));+ return s;}- public int nameCacheHitSize() {- HitMissCache c = getHitMissCache("id");- return c.hitCache.size();- }-- public int nameCacheMissSize() {- HitMissCache c = getHitMissCache("id");- return c.missCache.size();- }-- public int nameCacheDocumentSize() {- return this.documentCache.size();- }}diff --git a/source/net/yacy/cora/federate/solr/connector/MultipleSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/MultipleSolrConnector.javaindex 48bb94608..bfa73104a 100644--- a/source/net/yacy/cora/federate/solr/connector/MultipleSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/MultipleSolrConnector.java@@ -25,7 +25,6 @@ import java.util.List;import java.util.concurrent.ArrayBlockingQueue;import net.yacy.cora.federate.solr.instance.SolrInstance;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrException;@@ -40,7 +39,7 @@ public class MultipleSolrConnector extends AbstractSolrConnector implements Solrprivate final AddWorker[] worker;private final SolrConnector solr;- public MultipleSolrConnector(final SolrRemoteInstance instance, final String corename, final int connections) {+ public MultipleSolrConnector(final SolrInstance instance, final String corename, final int connections) {this.solr = new RemoteSolrConnector(instance, corename);this.queue = new ArrayBlockingQueue<SolrInputDocument>(1000);this.worker = new AddWorker[connections];@@ -52,7 +51,7 @@ public class MultipleSolrConnector extends AbstractSolrConnector implements Solrprivate class AddWorker extends Thread {private final SolrConnector solr;- public AddWorker(final SolrRemoteInstance instance, final String corename) {+ public AddWorker(final SolrInstance instance, final String corename) {this.solr = new RemoteSolrConnector(instance, corename);}@Overridediff --git a/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.javaindex 167129044..752043ca4 100644--- a/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java@@ -22,9 +22,11 @@ package net.yacy.cora.federate.solr.connector;import java.io.File;import java.io.IOException;+import java.util.ArrayList;import net.yacy.cora.federate.solr.instance.SolrInstance;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;+import net.yacy.cora.federate.solr.instance.RemoteInstance;+import net.yacy.cora.federate.solr.instance.ShardInstance;import org.apache.solr.client.solrj.ResponseParser;import org.apache.solr.client.solrj.SolrServer;@@ -36,7 +38,7 @@ import org.apache.solr.common.util.NamedList;public class RemoteSolrConnector extends SolrServerConnector implements SolrConnector {- SolrRemoteInstance instance;+ SolrInstance instance;String corename;/**@@ -44,7 +46,7 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConn* @param instance the instance of the remote solr url, like http://192.168.1.60:8983/solr/ or http://admin:[email protected]:8983/solr/* @throws IOException*/- public RemoteSolrConnector(final SolrRemoteInstance instance) throws IOException {+ public RemoteSolrConnector(final SolrInstance instance) throws IOException {super();this.instance = instance;this.corename = this.instance.getDefaultCoreName();@@ -52,7 +54,7 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConnsuper.init(s);}- public RemoteSolrConnector(final SolrRemoteInstance instance, String corename) {+ public RemoteSolrConnector(final SolrInstance instance, String corename) {super();this.instance = instance;this.corename = corename == null ? this.instance.getDefaultCoreName() : corename;@@ -102,8 +104,10 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConnpublic static void main(final String args[]) {RemoteSolrConnector solr;try {- SolrRemoteInstance instance = new SolrRemoteInstance("http://127.0.0.1:8983/solr/");- solr = new RemoteSolrConnector(instance, "solr");+ RemoteInstance instance = new RemoteInstance("http://127.0.0.1:8983/solr/", null, "collection1");+ ArrayList<RemoteInstance> instances = new ArrayList<RemoteInstance>();+ instances.add(instance);+ solr = new RemoteSolrConnector(new ShardInstance(instances, ShardSelection.Method.MODULO_HOST_MD5), "solr");solr.clear();final File exampleDir = new File("test/parsertest/");long t, t0, a = 0;diff --git a/source/net/yacy/cora/federate/solr/connector/RetrySolrConnector.java b/source/net/yacy/cora/federate/solr/connector/RetrySolrConnector.javaindex af2d813e9..5756fbf5d 100644--- a/source/net/yacy/cora/federate/solr/connector/RetrySolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/RetrySolrConnector.java@@ -23,8 +23,6 @@ package net.yacy.cora.federate.solr.connector;import java.io.IOException;import java.util.List;-import net.yacy.cora.federate.solr.instance.SolrInstance;-import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;diff --git a/source/net/yacy/cora/federate/solr/connector/ShardSelection.java b/source/net/yacy/cora/federate/solr/connector/ShardSelection.javaindex badb022f2..141966b57 100644--- a/source/net/yacy/cora/federate/solr/connector/ShardSelection.java+++ b/source/net/yacy/cora/federate/solr/connector/ShardSelection.java@@ -28,9 +28,11 @@ import java.security.NoSuchAlgorithmException;import java.util.concurrent.atomic.AtomicLong;import net.yacy.cora.document.ASCII;-import net.yacy.cora.federate.solr.YaCySchema;+import net.yacy.kelondro.logging.Log;+import net.yacy.search.schema.CollectionSchema;import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.common.SolrInputField;public class ShardSelection {@@ -53,28 +55,51 @@ public class ShardSelection {public int select(final SolrInputDocument solrdoc) throws IOException {if (this.method == Method.MODULO_HOST_MD5) {- final String sku = (String) solrdoc.getField(YaCySchema.sku.getSolrFieldName()).getValue();- return selectURL(sku);+ SolrInputField sif = solrdoc.getField(CollectionSchema.host_s.getSolrFieldName());+ if (sif != null) {+ final String host = (String) sif.getValue();+ return selectHost(host);+ }+ sif = solrdoc.getField(CollectionSchema.sku.getSolrFieldName());+ if (sif != null) {+ final String url = (String) sif.getValue();+ try {+ return selectURL(url);+ } catch (IOException e) {+ Log.logException(e);+ return 0;+ }+ }+ return 0;}// finally if no method matches use ROUND_ROBINreturn selectRoundRobin();}+ public int selectHost(final String host) throws IOException {+ if (this.method == Method.MODULO_HOST_MD5) {+ if (host == null) throw new IOException("sharding - host url, host empty: " + host);+ try {+ final MessageDigest digest = MessageDigest.getInstance("MD5");+ digest.update(ASCII.getBytes(host));+ final byte[] md5 = digest.digest();+ return (0xff & md5[0]) % this.dimension;+ } catch (final NoSuchAlgorithmException e) {+ throw new IOException("sharding - no md5 available: " + e.getMessage());+ }+ }++ // finally if no method matches use ROUND_ROBIN+ return (int) (this.chardID.getAndIncrement() % this.dimension);+ }+public int selectURL(final String sku) throws IOException {if (this.method == Method.MODULO_HOST_MD5) {try {final URL url = new URL(sku);final String host = url.getHost();- if (host == null) throw new IOException("sharding - bad url, host empty: " + sku);- try {- final MessageDigest digest = MessageDigest.getInstance("MD5");- digest.update(ASCII.getBytes(host));- final byte[] md5 = digest.digest();- return (0xff & md5[0]) % this.dimension;- } catch (final NoSuchAlgorithmException e) {- throw new IOException("sharding - no md5 available: " + e.getMessage());- }+ return selectHost(host);} catch (final MalformedURLException e) {throw new IOException("sharding - bad url: " + sku);}diff --git a/source/net/yacy/cora/federate/solr/connector/ShardSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/ShardSolrConnector.javaindex 407093c13..70b0c7e84 100644--- a/source/net/yacy/cora/federate/solr/connector/ShardSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/ShardSolrConnector.java@@ -26,69 +26,55 @@ import java.util.Collection;import java.util.HashMap;import java.util.List;import java.util.Map;+import java.util.concurrent.ConcurrentLinkedQueue;import java.util.concurrent.atomic.AtomicLong;import net.yacy.cora.sorting.ReversibleScoreMap;-import net.yacy.cora.federate.solr.instance.SolrInstance;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;+import net.yacy.cora.federate.solr.instance.ResponseAccumulator;+import net.yacy.cora.federate.solr.instance.RemoteInstance;-import org.apache.solr.client.solrj.response.FacetField;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.ModifiableSolrParams;-import org.apache.solr.common.util.NamedList;-import org.apache.solr.common.util.SimpleOrderedMap;public class ShardSolrConnector extends AbstractSolrConnector implements SolrConnector {- private final ArrayList<SolrRemoteInstance> instances;+ private final ArrayList<RemoteInstance> instances;private final ArrayList<SolrConnector> connectors;private final ShardSelection sharding;- private final String[] adminInterfaces;+ private final ArrayList<String> adminInterfaces;public ShardSolrConnector(- ArrayList<SolrRemoteInstance> instances,+ ArrayList<RemoteInstance> instances,final ShardSelection.Method method, boolean multipleConnections) {this.instances = instances;this.connectors = new ArrayList<SolrConnector>();SolrConnector s;- this.adminInterfaces = new String[instances.size()];- int c = 0;+ this.adminInterfaces = new ArrayList<String>(instances.size());String defaultCoreName = instances.get(0).getDefaultCoreName();- for (final SolrRemoteInstance instance: instances) {- adminInterfaces[c++] = instance.getAdminInterface();+ for (final RemoteInstance instance: instances) {+ adminInterfaces.add(instance.getAdminInterface());s = multipleConnections ? new MultipleSolrConnector(instance, defaultCoreName, 2) : new RemoteSolrConnector(instance, defaultCoreName);this.connectors.add(s /*new RetrySolrConnector(s, timeout)*/);}this.sharding = new ShardSelection(method, this.connectors.size());}- public static ArrayList<SolrRemoteInstance> getShardInstances(final String urlList) throws IOException {+ public static ArrayList<RemoteInstance> getShardInstances(final String urlList, Collection<String> coreNames, String defaultCoreName) throws IOException {urlList.replace(' ', ',');String[] urls = urlList.split(",");- ArrayList<SolrRemoteInstance> instances = new ArrayList<SolrRemoteInstance>();+ ArrayList<RemoteInstance> instances = new ArrayList<RemoteInstance>();for (final String u: urls) {- SolrRemoteInstance instance = new SolrRemoteInstance(u);- instances.add(instance);- }- return instances;- }-- public static ArrayList<SolrRemoteInstance> getShardInstances(final String urlList, Collection<String> coreNames, String defaultCoreName) throws IOException {- urlList.replace(' ', ',');- String[] urls = urlList.split(",");- ArrayList<SolrRemoteInstance> instances = new ArrayList<SolrRemoteInstance>();- for (final String u: urls) {- SolrRemoteInstance instance = new SolrRemoteInstance(u, coreNames, defaultCoreName);+ RemoteInstance instance = new RemoteInstance(u, coreNames, defaultCoreName);instances.add(instance);}return instances;}- public ArrayList<SolrRemoteInstance> getInstances() {+ public ArrayList<RemoteInstance> getInstances() {return this.instances;}@@ -220,52 +206,18 @@ public class ShardSolrConnector extends AbstractSolrConnector implements SolrCon@Overridepublic QueryResponse query(final ModifiableSolrParams query) throws IOException, SolrException {-- final SimpleOrderedMap<Object> facet_countsAcc = new SimpleOrderedMap<Object>();- final SimpleOrderedMap<Object> highlightingAcc = new SimpleOrderedMap<Object>();- final SimpleOrderedMap<Object> headerAcc = new SimpleOrderedMap<Object>();- final SolrDocumentList resultsAcc = new SolrDocumentList();-+ final Collection<QueryResponse> qrl = new ConcurrentLinkedQueue<QueryResponse>();// concurrently call all shardsList<Thread> t = new ArrayList<Thread>();for (final SolrConnector connector: this.connectors) {Thread t0 = new Thread() {- @SuppressWarnings("unchecked")@Overridepublic void run() {QueryResponse rsp;try {rsp = connector.query(query);} catch (Throwable e) {return;}- NamedList<Object> response = rsp.getResponse();-- // set the header; this is mostly always the same (well this is not evaluated much)- SimpleOrderedMap<Object> header = (SimpleOrderedMap<Object>) response.get("responseHeader");- //Integer status = (Integer) header.get("status");- //Integer QTime = (Integer) header.get("QTime");- //SimpleOrderedMap<Object> params = (SimpleOrderedMap<Object>) header.get("params");- if (headerAcc.size() == 0) {- for (Map.Entry<String, Object> e: header) headerAcc.add(e.getKey(), e.getValue());- }-- // accumulate the results- SolrDocumentList results = (SolrDocumentList) response.get("response");- long found = results.size();- for (int i = 0; i < found; i++) resultsAcc.add(results.get(i));- resultsAcc.setNumFound(resultsAcc.getNumFound() + results.getNumFound());- resultsAcc.setMaxScore(Math.max(resultsAcc.getMaxScore() == null ? 0f : resultsAcc.getMaxScore().floatValue(), results.getMaxScore() == null ? 0f : results.getMaxScore().floatValue()));-- // accumulate the highlighting- SimpleOrderedMap<Object> highlighting = (SimpleOrderedMap<Object>) response.get("highlighting");- if (highlighting != null) {- for (Map.Entry<String, Object> e: highlighting) highlightingAcc.add(e.getKey(), e.getValue());- }-- // accumulate the facets (well this is not correct at this time...)- SimpleOrderedMap<Object> facet_counts = (SimpleOrderedMap<Object>) response.get("facet_counts");- if (facet_counts != null) {- for (Map.Entry<String, Object> e: facet_counts) facet_countsAcc.add(e.getKey(), e.getValue());- }+ qrl.add(rsp);}};t0.start();@@ -276,14 +228,7 @@ public class ShardSolrConnector extends AbstractSolrConnector implements SolrCon}// prepare combined response- QueryResponse rspAcc = new QueryResponse();- NamedList<Object> nl = new NamedList<Object>();- nl.add("responseHeader", headerAcc);- nl.add("response", resultsAcc);- if (highlightingAcc != null && highlightingAcc.size() > 0) nl.add("highlighting", highlightingAcc);- if (facet_countsAcc != null && facet_countsAcc.size() > 0) nl.add("facet_counts", facet_countsAcc);- rspAcc.setResponse(nl);- return rspAcc;+ return ResponseAccumulator.combineResponses(qrl);}@Override@@ -343,7 +288,7 @@ public class ShardSolrConnector extends AbstractSolrConnector implements SolrConreturn s;}- public String[] getAdminInterfaceList() {+ public ArrayList<String> getAdminInterfaces() {return this.adminInterfaces;}diff --git a/source/net/yacy/cora/federate/solr/connector/SolrConnector.java b/source/net/yacy/cora/federate/solr/connector/SolrConnector.javaindex 94d114dd9..38a26431c 100644--- a/source/net/yacy/cora/federate/solr/connector/SolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/SolrConnector.java@@ -25,7 +25,6 @@ import java.util.List;import java.util.Map;import java.util.concurrent.BlockingQueue;-import net.yacy.cora.federate.solr.instance.SolrInstance;import net.yacy.cora.sorting.ReversibleScoreMap;import org.apache.solr.client.solrj.response.QueryResponse;diff --git a/source/net/yacy/cora/federate/solr/connector/SolrServerConnector.java b/source/net/yacy/cora/federate/solr/connector/SolrServerConnector.javaindex 92a35d604..537ca8b1b 100644--- a/source/net/yacy/cora/federate/solr/connector/SolrServerConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/SolrServerConnector.java@@ -24,12 +24,11 @@ import java.io.File;import java.io.IOException;import java.util.List;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.kelondro.logging.Log;+import net.yacy.search.schema.CollectionSchema;import org.apache.log4j.Logger;import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;-import org.apache.solr.client.solrj.impl.HttpSolrServer;import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;@@ -185,7 +184,7 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen} catch (Throwable e) {// catches "version conflict for": try this again and delete the document in advancetry {- this.server.deleteById((String) solrdoc.getFieldValue(YaCySchema.id.getSolrFieldName()));+ this.server.deleteById((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));} catch (SolrServerException e1) {}try {synchronized (this.server) {diff --git a/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java b/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.javanew file mode 100644index 000000000..c3388b4f3--- /dev/null+++ b/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java@@ -0,0 +1,181 @@+/**+ * EmbeddedInstance+ * Copyright 2013 by Michael Peter Christen+ * First released 13.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.cora.federate.solr.instance;++import java.io.File;+import java.io.IOException;+import java.util.Collection;+import java.util.Map;+import java.util.concurrent.ConcurrentHashMap;++import net.yacy.kelondro.logging.Log;+import net.yacy.kelondro.util.MemoryControl;++import org.apache.solr.client.solrj.SolrServer;+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;+import org.apache.solr.core.CoreContainer;+import org.apache.solr.core.SolrCore;++import com.google.common.io.Files;++public class EmbeddedInstance implements SolrInstance {++ private final static String[] confFiles = {"solrconfig.xml", "schema.xml", "stopwords.txt", "synonyms.txt", "protwords.txt", "currency.xml", "elevate.xml", "xslt/example.xsl", "xslt/json.xsl", "lang/"};++ private CoreContainer coreContainer;+ private String defaultCoreName;+ private SolrCore defaultCore;+ private SolrServer defaultCoreServer;+ private File containerPath;+ private Map<String, SolrCore> cores;+ private Map<String, SolrServer> server;++ public EmbeddedInstance(final File solr_config, final File containerPath, String givenDefaultCoreName, String[] initializeCoreNames) throws IOException {+ super();+ // copy the solrconfig.xml to the storage path+ this.containerPath = containerPath;++ // ensure that default core path exists+ File defaultCorePath = new File(containerPath, givenDefaultCoreName);+ if (!defaultCorePath.exists()) defaultCorePath.mkdirs();++ // migrate old conf directory+ File conf = new File(defaultCorePath, "conf");+ File oldConf = new File(containerPath, "conf");+ if (oldConf.exists()) oldConf.renameTo(conf);++ // migrate old data directory+ File oldData = new File(containerPath, "data");+ if (oldData.exists()) oldData.renameTo(new File(defaultCorePath, "data"));++ // initialize the cores' configuration+ for (String coreName: initializeCoreNames) {+ initializeCoreConf(solr_config, containerPath, coreName);+ }++ // initialize the coreContainer+ String containerDir = this.containerPath.getAbsolutePath(); // the home directory of all resources.+ File configFile = new File(solr_config, "solr.xml"); // the configuration file for all cores+ this.coreContainer = new CoreContainer(containerDir, configFile); // this may take indefinitely long if solr files are broken+ if (this.coreContainer == null) throw new IOException("cannot create core container dir = " + containerDir + ", configFile = " + configFile);++ // get the default core from the coreContainer+ this.defaultCoreName = this.coreContainer.getDefaultCoreName();+ assert(this.defaultCoreName.equals(givenDefaultCoreName));+ Log.logInfo("SolrEmbeddedInstance", "detected default solr core: " + this.defaultCoreName);+ this.defaultCore = this.coreContainer.getCore(this.defaultCoreName);+ assert givenDefaultCoreName.equals(this.defaultCore.getName()) : "givenDefaultCoreName = " + givenDefaultCoreName + ", this.defaultCore.getName() = " + this.defaultCore.getName();+ if (this.defaultCore == null) {+ throw new IOException("cannot get the default core; available = " + MemoryControl.available() + ", free = " + MemoryControl.free());+ }+ this.defaultCoreServer = new EmbeddedSolrServer(this.coreContainer, this.defaultCoreName);++ // initialize core cache+ this.cores = new ConcurrentHashMap<String, SolrCore>();+ this.cores.put(this.defaultCoreName, this.defaultCore);+ this.server = new ConcurrentHashMap<String, SolrServer>();+ this.server.put(this.defaultCoreName, this.defaultCoreServer);+ }++ private void initializeCoreConf(final File solr_config, final File containerPath, String coreName) {++ // ensure that default core path exists+ File corePath = new File(containerPath, coreName);+ if (!corePath.exists()) corePath.mkdirs();++ // ensure necessary subpaths exist+ File conf = new File(corePath, "conf");+ conf.mkdirs();+ File data = new File(corePath, "data");+ data.mkdirs();++ // (over-)write configuration into conf path+ File source, target;+ for (String cf: confFiles) {+ source = new File(solr_config, cf);+ if (source.isDirectory()) {+ target = new File(conf, cf);+ target.mkdirs();+ for (String cfl: source.list()) {+ try {+ Files.copy(new File(source, cfl), new File(target, cfl));+ } catch (IOException e) {+ e.printStackTrace();+ }+ }+ } else {+ target = new File(conf, cf);+ target.getParentFile().mkdirs();+ try {+ Files.copy(source, target);+ } catch (IOException e) {+ e.printStackTrace();+ }+ }+ }+ }++ public File getContainerPath() {+ return this.containerPath;+ }++ @Override+ public String getDefaultCoreName() {+ return this.defaultCoreName;+ }++ @Override+ public Collection<String> getCoreNames() {+ return this.coreContainer.getCoreNames();+ }++ @Override+ public SolrServer getDefaultServer() {+ return this.defaultCoreServer;+ }++ @Override+ public SolrServer getServer(String coreName) {+ SolrServer s = this.server.get(coreName);+ if (s != null) return s;+ s = new EmbeddedSolrServer(this.coreContainer, coreName);+ this.server.put(coreName, s);+ return s;+ }++ public SolrCore getDefaultCore() {+ return this.defaultCore;+ }++ public SolrCore getCore(String name) {+ SolrCore c = this.cores.get(name);+ if (c != null) return c;+ c = this.coreContainer.getCore(name);+ this.cores.put(name, c);+ return c;+ }++ @Override+ public synchronized void close() {+ try {this.coreContainer.shutdown();} catch (Throwable e) {Log.logException(e);}+ }++}diff --git a/source/net/yacy/cora/federate/solr/instance/InstanceMirror.java b/source/net/yacy/cora/federate/solr/instance/InstanceMirror.javanew file mode 100644index 000000000..46d804e0e--- /dev/null+++ b/source/net/yacy/cora/federate/solr/instance/InstanceMirror.java@@ -0,0 +1,137 @@+/**+ * InstanceMirror+ * Copyright 2013 by Michael Peter Christen+ * First released 18.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.cora.federate.solr.instance;++import java.util.Collection;+import java.util.HashMap;+import java.util.Map;++import net.yacy.cora.federate.solr.connector.CachedSolrConnector;+import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;+import net.yacy.cora.federate.solr.connector.MirrorSolrConnector;+import net.yacy.cora.federate.solr.connector.RemoteSolrConnector;+import net.yacy.cora.federate.solr.connector.SolrConnector;++public class InstanceMirror {++ private EmbeddedInstance solr0;+ private ShardInstance solr1;+ private CachedSolrConnector defaultConnector;+ private Map<String, CachedSolrConnector> connectorCache;++ public InstanceMirror() {+ this.solr0 = null;+ this.solr1 = null;+ this.defaultConnector = null;+ this.connectorCache = new HashMap<String, CachedSolrConnector>();+ }++ public boolean isConnected0() {+ return this.solr0 != null;+ }++ public void connect0(EmbeddedInstance c) {+ for (SolrConnector connector: connectorCache.values()) connector.close();+ this.connectorCache.clear();+ this.defaultConnector = null;+ this.solr0 = c;+ }++ public EmbeddedInstance getSolr0() {+ return this.solr0;+ }++ public void disconnect0() {+ if (this.solr0 == null) return;+ for (SolrConnector connector: connectorCache.values()) connector.close();+ this.connectorCache.clear();+ this.defaultConnector = null;+ this.solr0.close();+ this.solr0 = null;+ }++ public boolean isConnected1() {+ return this.solr1 != null;+ }++ public void connect1(ShardInstance c) {+ for (SolrConnector connector: connectorCache.values()) connector.close();+ this.connectorCache.clear();+ this.defaultConnector = null;+ this.solr1 = c;+ }++ public ShardInstance getSolr1() {+ return this.solr1;+ }++ public void disconnect1() {+ if (this.solr1 == null) return;+ for (SolrConnector connector: connectorCache.values()) connector.close();+ this.connectorCache.clear();+ this.defaultConnector = null;+ this.solr1.close();+ this.solr1 = null;+ }++ public synchronized void close() {+ this.disconnect0();+ this.disconnect1();+ }++ public String getDefaultCoreName() {+ if (this.solr0 != null) return this.solr0.getDefaultCoreName();+ if (this.solr1 != null) return this.solr1.getDefaultCoreName();+ return null;+ }++ public Collection<String> getCoreNames() {+ if (this.solr0 != null) return this.solr0.getCoreNames();+ if (this.solr1 != null) return this.solr1.getCoreNames();+ return null;+ }++ public SolrConnector getDefaultConnector() {+ if (this.defaultConnector != null) return this.defaultConnector;+ String defaultCoreName = this.getDefaultCoreName();+ if (defaultCoreName == null) return null;+ EmbeddedSolrConnector esc = this.solr0 == null ? null : new EmbeddedSolrConnector(this.solr0, defaultCoreName);+ RemoteSolrConnector rsc = this.solr1 == null ? null : new RemoteSolrConnector(this.solr1, defaultCoreName);+ this.defaultConnector = new CachedSolrConnector(new MirrorSolrConnector(esc, rsc), 10000, 1000, 100);+ this.connectorCache.put(defaultCoreName, this.defaultConnector);+ return this.defaultConnector;+ }++ public SolrConnector getConnector(String corename) {+ CachedSolrConnector msc = this.connectorCache.get(corename);+ if (msc != null) return msc;+ EmbeddedSolrConnector esc = this.solr0 == null ? null : new EmbeddedSolrConnector(this.solr0, corename);+ RemoteSolrConnector rsc = this.solr1 == null ? null : new RemoteSolrConnector(this.solr1, corename);+ msc = new CachedSolrConnector(new MirrorSolrConnector(esc, rsc), 10000, 1000, 100);+ this.connectorCache.put(corename, msc);+ return msc;+ }++ public void clearCache() {+ for (CachedSolrConnector csc: this.connectorCache.values()) csc.clearCache();+ }++}diff --git a/source/net/yacy/cora/federate/solr/instance/SolrRemoteInstance.java b/source/net/yacy/cora/federate/solr/instance/RemoteInstance.javasimilarity index 83%rename from source/net/yacy/cora/federate/solr/instance/SolrRemoteInstance.javarename to source/net/yacy/cora/federate/solr/instance/RemoteInstance.javaindex 7bc3100bf..4d9d79ab8 100644--- a/source/net/yacy/cora/federate/solr/instance/SolrRemoteInstance.java+++ b/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java@@ -1,5 +1,5 @@/**- * SolrRemoteInstance+ * RemoteInstance* Copyright 2013 by Michael Peter Christen* First released 13.02.2013 at http://yacy.net*@@ -25,10 +25,14 @@ import java.net.InetAddress;import java.net.MalformedURLException;import java.util.ArrayList;import java.util.Collection;+import java.util.HashMap;+import java.util.Map;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.protocol.Domains;import net.yacy.kelondro.logging.Log;+import net.yacy.search.schema.CollectionSchema;+import net.yacy.search.schema.WebgraphSchema;import org.apache.commons.httpclient.HttpException;import org.apache.http.Header;@@ -53,25 +57,31 @@ import org.apache.http.protocol.HttpContext;import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.impl.HttpSolrServer;-public class SolrRemoteInstance implements SolrInstance {+public class RemoteInstance implements SolrInstance {private String solrurl;- private DefaultHttpClient client;+ private final DefaultHttpClient client;- private String defaultCoreName;- private HttpSolrServer defaultServer;- private Collection<String> coreNames;+ private final String defaultCoreName;+ private final HttpSolrServer defaultServer;+ private final Collection<String> coreNames;+ private final Map<String, HttpSolrServer> server;- public SolrRemoteInstance(final String url) throws IOException {- this(url, null, url.endsWith("solr/") || url.endsWith("solr") ? "solr" : "shard0");+ /*+ public RemoteInstance(final String url) throws IOException {+ this(url, null, url.endsWith("solr/") || url.endsWith("solr") ? "solr" : CollectionSchema.CORE_NAME);}+ */- public SolrRemoteInstance(final String url, final Collection<String> coreNames, final String defaultCoreName) throws IOException {- this.solrurl = url;- if (this.solrurl == null) this.solrurl = "http://127.0.0.1:8983/solr/"; // that should work for the example configuration of solr 4.x.x+ public RemoteInstance(final String url, final Collection<String> coreNames, final String defaultCoreName) throws IOException {+ this.server= new HashMap<String, HttpSolrServer>();+ this.solrurl = url == null ? "http://127.0.0.1:8983/solr/" : url; // that should work for the example configuration of solr 4.x.xthis.coreNames = coreNames == null ? new ArrayList<String>() : coreNames;- this.defaultCoreName = defaultCoreName;- if (this.defaultCoreName == null) this.defaultCoreName = "shard0";+ if (this.coreNames.size() == 0) {+ this.coreNames.add(CollectionSchema.CORE_NAME);+ this.coreNames.add(WebgraphSchema.CORE_NAME);+ }+ this.defaultCoreName = defaultCoreName == null ? CollectionSchema.CORE_NAME : defaultCoreName;if (!this.coreNames.contains(this.defaultCoreName)) this.coreNames.add(this.defaultCoreName);// check the url@@ -193,7 +203,10 @@ public class SolrRemoteInstance implements SolrInstance {@Overridepublic SolrServer getServer(String name) {- HttpSolrServer server;+ // try to get the server from the cache+ HttpSolrServer s = this.server.get(name);+ if (s != null) return s;+ // create new http serverif (this.client != null) {final MultiProtocolURI u;try {@@ -206,16 +219,17 @@ public class SolrRemoteInstance implements SolrInstance {String solrpath = u.getPath();String p = "http://" + host + ":" + port + solrpath;Log.logInfo("RemoteSolrConnector", "connecting Solr authenticated with url:" + p);- server = new HttpSolrServer(p, client);+ s = new HttpSolrServer(p, client);} else {Log.logInfo("RemoteSolrConnector", "connecting Solr with url:" + this.solrurl + name);- server = new HttpSolrServer(this.solrurl + name);+ s = new HttpSolrServer(this.solrurl + name);}- server.setAllowCompression(true);- server.setConnectionTimeout(60000);- server.setMaxRetries(1); // Solr-Doc: No more than 1 recommended (depreciated)- server.setSoTimeout(60000);- return server;+ s.setAllowCompression(true);+ s.setConnectionTimeout(60000);+ s.setMaxRetries(1); // Solr-Doc: No more than 1 recommended (depreciated)+ s.setSoTimeout(60000);+ this.server.put(name, s);+ return s;}@Overridediff --git a/source/net/yacy/cora/federate/solr/instance/ResponseAccumulator.java b/source/net/yacy/cora/federate/solr/instance/ResponseAccumulator.javanew file mode 100644index 000000000..49a98bbb3--- /dev/null+++ b/source/net/yacy/cora/federate/solr/instance/ResponseAccumulator.java@@ -0,0 +1,101 @@+/**+ * ResponseAccumulator+ * Copyright 2013 by Michael Peter Christen+ * First released 13.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.cora.federate.solr.instance;++import java.util.Collection;+import java.util.Map;++import org.apache.solr.client.solrj.response.QueryResponse;+import org.apache.solr.common.SolrDocumentList;+import org.apache.solr.common.util.NamedList;+import org.apache.solr.common.util.SimpleOrderedMap;++public class ResponseAccumulator {++ final SimpleOrderedMap<Object> facet_countsAcc;+ final SimpleOrderedMap<Object> highlightingAcc;+ final SimpleOrderedMap<Object> headerAcc;+ final SolrDocumentList resultsAcc;++ public ResponseAccumulator() {+ this.facet_countsAcc = new SimpleOrderedMap<Object>();+ this.highlightingAcc = new SimpleOrderedMap<Object>();+ this.headerAcc = new SimpleOrderedMap<Object>();+ this.resultsAcc = new SolrDocumentList();++ }++ public void addResponse(NamedList<Object> response) {+ // set the header; this is mostly always the same (well this is not evaluated much)+ @SuppressWarnings("unchecked")+ SimpleOrderedMap<Object> header = (SimpleOrderedMap<Object>) response.get("responseHeader");+ //Integer status = (Integer) header.get("status");+ //Integer QTime = (Integer) header.get("QTime");+ //SimpleOrderedMap<Object> params = (SimpleOrderedMap<Object>) header.get("params");+ if (headerAcc.size() == 0) {+ for (Map.Entry<String, Object> e: header) headerAcc.add(e.getKey(), e.getValue());+ }++ // accumulate the results+ SolrDocumentList results = (SolrDocumentList) response.get("response");+ long found = results.size();+ for (int i = 0; i < found; i++) resultsAcc.add(results.get(i));+ resultsAcc.setNumFound(resultsAcc.getNumFound() + results.getNumFound());+ resultsAcc.setMaxScore(Math.max(resultsAcc.getMaxScore() == null ? 0f : resultsAcc.getMaxScore().floatValue(), results.getMaxScore() == null ? 0f : results.getMaxScore().floatValue()));++ // accumulate the highlighting+ @SuppressWarnings("unchecked")+ SimpleOrderedMap<Object> highlighting = (SimpleOrderedMap<Object>) response.get("highlighting");+ if (highlighting != null) {+ for (Map.Entry<String, Object> e: highlighting) highlightingAcc.add(e.getKey(), e.getValue());+ }++ // accumulate the facets (well this is not correct at this time...)+ @SuppressWarnings("unchecked")+ SimpleOrderedMap<Object> facet_counts = (SimpleOrderedMap<Object>) response.get("facet_counts");+ if (facet_counts != null) {+ for (Map.Entry<String, Object> e: facet_counts) facet_countsAcc.add(e.getKey(), e.getValue());+ }+ }++ public NamedList<Object> getAccumulatedResponse() {+ // prepare combined response+ NamedList<Object> responsesAcc = new NamedList<Object>();+ responsesAcc.add("responseHeader", headerAcc);+ responsesAcc.add("response", resultsAcc);+ if (highlightingAcc != null && highlightingAcc.size() > 0) responsesAcc.add("highlighting", highlightingAcc);+ if (facet_countsAcc != null && facet_countsAcc.size() > 0) responsesAcc.add("facet_counts", facet_countsAcc);+ return responsesAcc;+ }++ public static QueryResponse combineResponses(Collection<QueryResponse> qrl) {+ ResponseAccumulator acc = new ResponseAccumulator();+ for (final QueryResponse rsp: qrl) {+ NamedList<Object> response = rsp.getResponse();+ acc.addResponse(response);+ }++ // prepare combined response+ QueryResponse rspAcc = new QueryResponse();+ rspAcc.setResponse(acc.getAccumulatedResponse());+ return rspAcc;+ }+}diff --git a/source/net/yacy/cora/federate/solr/instance/ServerMirror.java b/source/net/yacy/cora/federate/solr/instance/ServerMirror.javanew file mode 100644index 000000000..ec4dc327d--- /dev/null+++ b/source/net/yacy/cora/federate/solr/instance/ServerMirror.java@@ -0,0 +1,410 @@+/**+ * ServerMirror+ * Copyright 2013 by Michael Peter Christen+ * First released 18.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.cora.federate.solr.instance;++import java.io.IOException;+import java.util.Collection;+import java.util.List;++import org.apache.solr.client.solrj.SolrRequest;+import org.apache.solr.client.solrj.SolrServer;+import org.apache.solr.client.solrj.SolrServerException;+import org.apache.solr.client.solrj.StreamingResponseCallback;+import org.apache.solr.client.solrj.SolrRequest.METHOD;+import org.apache.solr.client.solrj.beans.DocumentObjectBinder;+import org.apache.solr.client.solrj.response.QueryResponse;+import org.apache.solr.client.solrj.response.SolrPingResponse;+import org.apache.solr.client.solrj.response.UpdateResponse;+import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.common.params.SolrParams;+import org.apache.solr.common.util.NamedList;++public class ServerMirror extends SolrServer {++ private static final long serialVersionUID = 4665364470785220322L;+ private SolrServer solr0, solr1;++ public ServerMirror() {+ solr0 = null;+ solr1 = null;+ }++ public void connect0(SolrServer solr0) {+ this.solr0 = solr0;+ }++ public void connect1(SolrServer solr1) {+ this.solr1 = solr1;+ }++ /**+ * Adds a collection of documents+ * @param docs the collection of documents+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse add(Collection<SolrInputDocument> docs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.add(docs);+ if (this.solr1 != null) ur = this.solr1.add(docs);+ return ur;+ }++ /**+ * Adds a collection of documents, specifying max time before they become committed+ * @param docs the collection of documents+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse add(Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.add(docs, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.add(docs, commitWithinMs);+ return ur;+ }++ /**+ * Adds a collection of beans+ * @param beans the collection of beans+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse addBeans(Collection<?> beans ) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.addBeans(beans);+ if (this.solr1 != null) ur = this.solr1.addBeans(beans);+ return ur;+ }++ /**+ * Adds a collection of beans specifying max time before they become committed+ * @param beans the collection of beans+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse addBeans(Collection<?> beans, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.addBeans(beans, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.addBeans(beans, commitWithinMs);+ return ur;+ }++ /**+ * Adds a single document+ * @param doc the input document+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse add(SolrInputDocument doc) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.add(doc);+ if (this.solr1 != null) ur = this.solr1.add(doc);+ return ur;+ }++ /**+ * Adds a single document specifying max time before it becomes committed+ * @param doc the input document+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse add(SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.add(doc, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.add(doc, commitWithinMs);+ return ur;+ }++ /**+ * Adds a single bean+ * @param obj the input bean+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse addBean(Object obj) throws IOException, SolrServerException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.addBean(obj);+ if (this.solr1 != null) ur = this.solr1.addBean(obj);+ return ur;+ }++ /**+ * Adds a single bean specifying max time before it becomes committed+ * @param obj the input bean+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse addBean(Object obj, int commitWithinMs) throws IOException, SolrServerException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.addBean(obj, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.addBean(obj, commitWithinMs);+ return ur;+ }++ /**+ * Performs an explicit commit, causing pending documents to be committed for indexing+ * <p>+ * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse commit() throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.commit();+ if (this.solr1 != null) ur = this.solr1.commit();+ return ur;+ }++ /**+ * Performs an explicit optimize, causing a merge of all segments to one.+ * <p>+ * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access+ * <p>+ * Note: In most cases it is not required to do explicit optimize+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse optimize() throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.optimize();+ if (this.solr1 != null) ur = this.solr1.optimize();+ return ur;+ }++ /**+ * Performs an explicit commit, causing pending documents to be committed for indexing+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.commit(waitFlush, waitSearcher);+ if (this.solr1 != null) ur = this.solr1.commit(waitFlush, waitSearcher);+ return ur;+ }++ /**+ * Performs an explicit commit, causing pending documents to be committed for indexing+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @param softCommit makes index changes visible while neither fsync-ing index files nor writing a new index descriptor+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse commit( boolean waitFlush, boolean waitSearcher, boolean softCommit ) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.commit(waitFlush, waitSearcher, softCommit);+ if (this.solr1 != null) ur = this.solr1.commit(waitFlush, waitSearcher, softCommit);+ return ur;+ }++ /**+ * Performs an explicit optimize, causing a merge of all segments to one.+ * <p>+ * Note: In most cases it is not required to do explicit optimize+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.optimize(waitFlush, waitSearcher);+ if (this.solr1 != null) ur = this.solr1.optimize(waitFlush, waitSearcher);+ return ur;+ }++ /**+ * Performs an explicit optimize, causing a merge of all segments to one.+ * <p>+ * Note: In most cases it is not required to do explicit optimize+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @param maxSegments optimizes down to at most this number of segments+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher, int maxSegments ) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.optimize(waitFlush, waitSearcher, maxSegments);+ if (this.solr1 != null) ur = this.solr1.optimize(waitFlush, waitSearcher, maxSegments);+ return ur;+ }++ /**+ * Performs a rollback of all non-committed documents pending.+ * <p>+ * Note that this is not a true rollback as in databases. Content you have previously+ * added may have been committed due to autoCommit, buffer full, other client performing+ * a commit etc.+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse rollback() throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.rollback();+ if (this.solr1 != null) ur = this.solr1.rollback();+ return ur;+ }++ /**+ * Deletes a single document by unique ID+ * @param id the ID of the document to delete+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse deleteById(String id) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.deleteById(id);+ if (this.solr1 != null) ur = this.solr1.deleteById(id);+ return ur;+ }++ /**+ * Deletes a single document by unique ID, specifying max time before commit+ * @param id the ID of the document to delete+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since 3.6+ */+ public UpdateResponse deleteById(String id, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.deleteById(id, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.deleteById(id, commitWithinMs);+ return ur;+ }++ /**+ * Deletes a list of documents by unique ID+ * @param ids the list of document IDs to delete+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse deleteById(List<String> ids) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.deleteById(ids);+ if (this.solr1 != null) ur = this.solr1.deleteById(ids);+ return ur;+ }++ /**+ * Deletes a list of documents by unique ID, specifying max time before commit+ * @param ids the list of document IDs to delete+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since 3.6+ */+ public UpdateResponse deleteById(List<String> ids, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.deleteById(ids, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.deleteById(ids, commitWithinMs);+ return ur;+ }++ /**+ * Deletes documents from the index based on a query+ * @param query the query expressing what documents to delete+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse deleteByQuery(String query) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.deleteByQuery(query);+ if (this.solr1 != null) ur = this.solr1.deleteByQuery(query);+ return ur;+ }++ /**+ * Deletes documents from the index based on a query, specifying max time before commit+ * @param query the query expressing what documents to delete+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since 3.6+ */+ public UpdateResponse deleteByQuery(String query, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ if (this.solr0 != null) ur = this.solr0.deleteByQuery(query, commitWithinMs);+ if (this.solr1 != null) ur = this.solr1.deleteByQuery(query, commitWithinMs);+ return ur;+ }++ /**+ * Issues a ping request to check if the server is alive+ * @throws IOException If there is a low-level I/O error.+ */+ public SolrPingResponse ping() throws SolrServerException, IOException {+ if (this.solr0 != null) return this.solr0.ping();+ if (this.solr1 != null) return this.solr1.ping();+ return null;+ }++ /**+ * Performs a query to the Solr server+ * @param params an object holding all key/value parameters to send along the request+ */+ public QueryResponse query(SolrParams params) throws SolrServerException {+ if (this.solr0 != null) return this.solr0.query(params);+ if (this.solr1 != null) return this.solr1.query(params);+ return null;+ }++ /**+ * Performs a query to the Solr server+ * @param params an object holding all key/value parameters to send along the request+ * @param method specifies the HTTP method to use for the request, such as GET or POST+ */+ public QueryResponse query(SolrParams params, METHOD method) throws SolrServerException {+ if (this.solr0 != null) return this.solr0.query(params, method);+ if (this.solr1 != null) return this.solr1.query(params, method);+ return null;+ }++ /**+ * Query solr, and stream the results. Unlike the standard query, this will+ * send events for each Document rather then add them to the QueryResponse.+ *+ * Although this function returns a 'QueryResponse' it should be used with care+ * since it excludes anything that was passed to callback. Also note that+ * future version may pass even more info to the callback and may not return+ * the results in the QueryResponse.+ *+ * @since solr 4.0+ */+ public QueryResponse queryAndStreamResponse( SolrParams params, StreamingResponseCallback callback ) throws SolrServerException, IOException {+ if (this.solr0 != null) return this.solr0.queryAndStreamResponse(params, callback);+ if (this.solr1 != null) return this.solr1.queryAndStreamResponse(params, callback);+ return null;+ }++ /**+ * SolrServer implementations need to implement how a request is actually processed+ */+ public NamedList<Object> request( final SolrRequest request ) throws SolrServerException, IOException {+ if (this.solr0 != null) return this.solr0.request(request);+ if (this.solr1 != null) return this.solr1.request(request);+ return null;+ }++ public DocumentObjectBinder getBinder() {+ if (this.solr0 != null) return this.solr0.getBinder();+ if (this.solr1 != null) return this.solr1.getBinder();+ return null;+ }++ @Override+ public void shutdown() {+ if (this.solr0 != null) this.solr0.shutdown();+ if (this.solr1 != null) this.solr1.shutdown();+ }++}diff --git a/source/net/yacy/cora/federate/solr/instance/ServerShard.java b/source/net/yacy/cora/federate/solr/instance/ServerShard.javanew file mode 100644index 000000000..de3190cd6--- /dev/null+++ b/source/net/yacy/cora/federate/solr/instance/ServerShard.java@@ -0,0 +1,430 @@+/**+ * ServerShard+ * Copyright 2013 by Michael Peter Christen+ * First released 13.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */+++package net.yacy.cora.federate.solr.instance;++import java.io.IOException;+import java.util.ArrayList;+import java.util.Collection;+import java.util.List;+import java.util.concurrent.ConcurrentLinkedQueue;++import org.apache.solr.client.solrj.SolrRequest;+import org.apache.solr.client.solrj.SolrServer;+import org.apache.solr.client.solrj.SolrServerException;+import org.apache.solr.client.solrj.StreamingResponseCallback;+import org.apache.solr.client.solrj.SolrRequest.METHOD;+import org.apache.solr.client.solrj.beans.DocumentObjectBinder;+import org.apache.solr.client.solrj.response.QueryResponse;+import org.apache.solr.client.solrj.response.SolrPingResponse;+import org.apache.solr.client.solrj.response.UpdateResponse;+import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.common.params.SolrParams;+import org.apache.solr.common.util.NamedList;++import net.yacy.cora.federate.solr.connector.ShardSelection;++public class ServerShard extends SolrServer {++ private static final long serialVersionUID = -3524175189049786312L;++ ArrayList<SolrServer> server;+ ShardSelection sharding;++ public ServerShard(ArrayList<SolrServer> server, final ShardSelection.Method method) {+ this.server = server;+ this.sharding = new ShardSelection(method, this.server.size());+ }++ /**+ * Adds a collection of documents+ * @param docs the collection of documents+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse add(Collection<SolrInputDocument> docs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrInputDocument doc: docs) ur = server.get(this.sharding.select(doc)).add(doc);+ return ur; // TODO: this accumlation of update responses is wrong, but sufficient (because we do not evaluate it)+ }++ /**+ * Adds a collection of documents, specifying max time before they become committed+ * @param docs the collection of documents+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse add(Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrInputDocument doc: docs) ur = server.get(this.sharding.select(doc)).add(doc, commitWithinMs);+ return ur;+ }++ /**+ * Adds a collection of beans+ * @param beans the collection of beans+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse addBeans(Collection<?> beans ) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.addBeans(beans);+ return ur;+ }++ /**+ * Adds a collection of beans specifying max time before they become committed+ * @param beans the collection of beans+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse addBeans(Collection<?> beans, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.addBeans(beans, commitWithinMs);+ return ur;+ }++ /**+ * Adds a single document+ * @param doc the input document+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse add(SolrInputDocument doc) throws SolrServerException, IOException {+ return server.get(this.sharding.select(doc)).add(doc);+ }++ /**+ * Adds a single document specifying max time before it becomes committed+ * @param doc the input document+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse add(SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException {+ return server.get(this.sharding.select(doc)).add(doc, commitWithinMs);+ }++ /**+ * Adds a single bean+ * @param obj the input bean+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse addBean(Object obj) throws IOException, SolrServerException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.addBean(obj);+ return ur;+ }++ /**+ * Adds a single bean specifying max time before it becomes committed+ * @param obj the input bean+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since solr 3.5+ */+ public UpdateResponse addBean(Object obj, int commitWithinMs) throws IOException, SolrServerException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.addBean(obj, commitWithinMs);+ return ur;+ }++ /**+ * Performs an explicit commit, causing pending documents to be committed for indexing+ * <p>+ * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse commit() throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.commit();+ return ur;+ }++ /**+ * Performs an explicit optimize, causing a merge of all segments to one.+ * <p>+ * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access+ * <p>+ * Note: In most cases it is not required to do explicit optimize+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse optimize() throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.optimize();+ return ur;+ }++ /**+ * Performs an explicit commit, causing pending documents to be committed for indexing+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.commit(waitFlush, waitSearcher);+ return ur;+ }++ /**+ * Performs an explicit commit, causing pending documents to be committed for indexing+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @param softCommit makes index changes visible while neither fsync-ing index files nor writing a new index descriptor+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher, boolean softCommit) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.commit(waitFlush, waitSearcher, softCommit);+ return ur;+ }++ /**+ * Performs an explicit optimize, causing a merge of all segments to one.+ * <p>+ * Note: In most cases it is not required to do explicit optimize+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.optimize(waitFlush, waitSearcher);+ return ur;+ }++ /**+ * Performs an explicit optimize, causing a merge of all segments to one.+ * <p>+ * Note: In most cases it is not required to do explicit optimize+ * @param waitFlush block until index changes are flushed to disk+ * @param waitSearcher block until a new searcher is opened and registered as the main query searcher, making the changes visible+ * @param maxSegments optimizes down to at most this number of segments+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher, int maxSegments) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.optimize(waitFlush, waitSearcher, maxSegments);+ return ur;+ }++ /**+ * Performs a rollback of all non-committed documents pending.+ * <p>+ * Note that this is not a true rollback as in databases. Content you have previously+ * added may have been committed due to autoCommit, buffer full, other client performing+ * a commit etc.+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse rollback() throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.rollback();+ return ur;+ }++ /**+ * Deletes a single document by unique ID+ * @param id the ID of the document to delete+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse deleteById(String id) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.deleteById(id);+ return ur;+ }++ /**+ * Deletes a single document by unique ID, specifying max time before commit+ * @param id the ID of the document to delete+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since 3.6+ */+ public UpdateResponse deleteById(String id, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.deleteById(id, commitWithinMs);+ return ur;+ }++ /**+ * Deletes a list of documents by unique ID+ * @param ids the list of document IDs to delete+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse deleteById(List<String> ids) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.deleteById(ids);+ return ur;+ }++ /**+ * Deletes a list of documents by unique ID, specifying max time before commit+ * @param ids the list of document IDs to delete+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since 3.6+ */+ public UpdateResponse deleteById(List<String> ids, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.deleteById(ids, commitWithinMs);+ return ur;+ }++ /**+ * Deletes documents from the index based on a query+ * @param query the query expressing what documents to delete+ * @throws IOException If there is a low-level I/O error.+ */+ public UpdateResponse deleteByQuery(String query) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.deleteByQuery(query);+ return ur;+ }++ /**+ * Deletes documents from the index based on a query, specifying max time before commit+ * @param query the query expressing what documents to delete+ * @param commitWithinMs max time (in ms) before a commit will happen+ * @throws IOException If there is a low-level I/O error.+ * @since 3.6+ */+ public UpdateResponse deleteByQuery(String query, int commitWithinMs) throws SolrServerException, IOException {+ UpdateResponse ur = null;+ for (SolrServer s: server) ur = s.deleteByQuery(query, commitWithinMs);+ return ur;+ }++ /**+ * Issues a ping request to check if the server is alive+ * @throws IOException If there is a low-level I/O error.+ */+ public SolrPingResponse ping() throws SolrServerException, IOException {+ for (SolrServer s: server) {+ SolrPingResponse spr = s.ping();+ if (spr != null) return spr;+ }+ return null;+ }++ /**+ * Performs a query to the Solr server+ * @param params an object holding all key/value parameters to send along the request+ */+ public QueryResponse query(final SolrParams params) throws SolrServerException {++ final Collection<QueryResponse> qrl = new ConcurrentLinkedQueue<QueryResponse>();+ // concurrently call all shards+ List<Thread> t = new ArrayList<Thread>();+ for (final SolrServer s: server) {+ Thread t0 = new Thread() {+ @Override+ public void run() {+ QueryResponse rsp;+ try {+ rsp = s.query(params);+ } catch (Throwable e) {return;}+ qrl.add(rsp);+ }+ };+ t0.start();+ t.add(t0);+ }+ for (Thread t0: t) {+ try {t0.join();} catch (InterruptedException e) {}+ }++ // prepare combined response+ return ResponseAccumulator.combineResponses(qrl);+ }++ /**+ * Performs a query to the Solr server+ * @param params an object holding all key/value parameters to send along the request+ * @param method specifies the HTTP method to use for the request, such as GET or POST+ */+ public QueryResponse query(final SolrParams params, final METHOD method) throws SolrServerException {++ final Collection<QueryResponse> qrl = new ConcurrentLinkedQueue<QueryResponse>();+ // concurrently call all shards+ List<Thread> t = new ArrayList<Thread>();+ for (final SolrServer s: server) {+ Thread t0 = new Thread() {+ @Override+ public void run() {+ QueryResponse rsp;+ try {+ rsp = s.query(params, method);+ } catch (Throwable e) {return;}+ qrl.add(rsp);+ }+ };+ t0.start();+ t.add(t0);+ }+ for (Thread t0: t) {+ try {t0.join();} catch (InterruptedException e) {}+ }++ // prepare combined response+ return ResponseAccumulator.combineResponses(qrl);+ }+++ /**+ * Query solr, and stream the results. Unlike the standard query, this will+ * send events for each Document rather then add them to the QueryResponse.+ *+ * Although this function returns a 'QueryResponse' it should be used with care+ * since it excludes anything that was passed to callback. Also note that+ * future version may pass even more info to the callback and may not return+ * the results in the QueryResponse.+ *+ * @since solr 4.0+ */+ public QueryResponse queryAndStreamResponse( SolrParams params, StreamingResponseCallback callback ) throws SolrServerException, IOException {+ throw new UnsupportedOperationException("stream response not possible with shards");+ }++ /**+ * SolrServer implementations need to implement how a request is actually processed+ */+ public NamedList<Object> request(final SolrRequest request) throws SolrServerException, IOException {+ ResponseAccumulator acc = new ResponseAccumulator();+ for (SolrServer s: server) acc.addResponse(s.request(request));+ return acc.getAccumulatedResponse();+ }++ public DocumentObjectBinder getBinder() {+ DocumentObjectBinder db;+ for (SolrServer s: server) {+ db = s.getBinder();+ if (db != null) return db;+ }+ return null;+ }++ @Override+ public void shutdown() {+ for (SolrServer s: server) {+ s.shutdown();+ }+ }+}diff --git a/source/net/yacy/cora/federate/solr/instance/ShardInstance.java b/source/net/yacy/cora/federate/solr/instance/ShardInstance.javanew file mode 100644index 000000000..1400b0042--- /dev/null+++ b/source/net/yacy/cora/federate/solr/instance/ShardInstance.java@@ -0,0 +1,87 @@+/**+ * ShardInstance+ * Copyright 2013 by Michael Peter Christen+ * First released 13.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */+++package net.yacy.cora.federate.solr.instance;++import java.util.ArrayList;+import java.util.Collection;+import java.util.Map;+import java.util.concurrent.ConcurrentHashMap;++import net.yacy.cora.federate.solr.connector.ShardSelection;++import org.apache.solr.client.solrj.SolrServer;++public class ShardInstance implements SolrInstance {++ private final ArrayList<RemoteInstance> instances;+ private final ShardSelection.Method method;+ private SolrServer defaultServer;+ private Map<String, SolrServer> serverCache;++ public ShardInstance(final ArrayList<RemoteInstance> instances, final ShardSelection.Method method) {+ this.instances = instances;+ this.method = method;+ this.defaultServer = null;+ this.serverCache = new ConcurrentHashMap<String, SolrServer>();+ }++ @Override+ public String getDefaultCoreName() {+ return instances.get(0).getDefaultCoreName();+ }++ @Override+ public Collection<String> getCoreNames() {+ return instances.get(0).getCoreNames();+ }++ @Override+ public SolrServer getDefaultServer() {+ if (this.defaultServer != null) return this.defaultServer;+ ArrayList<SolrServer> server = new ArrayList<SolrServer>(instances.size());+ for (int i = 0; i < instances.size(); i++) server.set(i, instances.get(i).getDefaultServer());+ this.defaultServer = new ServerShard(server, method);+ return this.defaultServer;+ }++ @Override+ public SolrServer getServer(String name) {+ SolrServer s = serverCache.get(name);+ if (s != null) return s;+ ArrayList<SolrServer> server = new ArrayList<SolrServer>(instances.size());+ for (int i = 0; i < instances.size(); i++) server.add(i, instances.get(i).getServer(name));+ s = new ServerShard(server, method);+ this.serverCache.put(name, s);+ return s;+ }++ @Override+ public void close() {+ for (RemoteInstance instance: instances) instance.close();+ }++ public ArrayList<String> getAdminInterfaces() {+ ArrayList<String> a = new ArrayList<String>();+ for (RemoteInstance i: this.instances) a.add(i.getAdminInterface());+ return a;+ }+}diff --git a/source/net/yacy/cora/federate/solr/instance/SolrEmbeddedInstance.java b/source/net/yacy/cora/federate/solr/instance/SolrEmbeddedInstance.javadeleted file mode 100644index 7cb9b2c47..000000000--- a/source/net/yacy/cora/federate/solr/instance/SolrEmbeddedInstance.java+++ /dev/null@@ -1,135 +0,0 @@-/**- * SolrEmbeddedInstance- * Copyright 2013 by Michael Peter Christen- * First released 13.02.2013 at http://yacy.net- *- * This library is free software; you can redistribute it and/or- * modify it under the terms of the GNU Lesser General Public- * License as published by the Free Software Foundation; either- * version 2.1 of the License, or (at your option) any later version.- *- * This library is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU- * Lesser General Public License for more details.- *- * You should have received a copy of the GNU Lesser General Public License- * along with this program in the file lgpl21.txt- * If not, see <http://www.gnu.org/licenses/>.- */--package net.yacy.cora.federate.solr.instance;--import java.io.File;-import java.io.IOException;-import java.util.Collection;--import net.yacy.kelondro.logging.Log;-import net.yacy.kelondro.util.MemoryControl;--import org.apache.solr.client.solrj.SolrServer;-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;-import org.apache.solr.core.CoreContainer;-import org.apache.solr.core.SolrCore;--import com.google.common.io.Files;--public class SolrEmbeddedInstance implements SolrInstance {-- private final static String[] confFiles = {"solrconfig.xml", "schema.xml", "stopwords.txt", "synonyms.txt", "protwords.txt", "currency.xml", "elevate.xml", "xslt/example.xsl", "xslt/json.xsl", "lang/"};-- private CoreContainer cores;- private String defaultCoreName;- private SolrCore defaultCore;- private SolrServer defaultServer;- private File storagePath;-- public SolrEmbeddedInstance(final File corePath, final File solr_config) throws IOException {- super();- // copy the solrconfig.xml to the storage path- this.storagePath = corePath;- File conf = new File(corePath, "conf");- conf.mkdirs();- File source, target;- for (String cf: confFiles) {- source = new File(solr_config, cf);- if (source.isDirectory()) {- target = new File(conf, cf);- target.mkdirs();- for (String cfl: source.list()) {- try {- Files.copy(new File(source, cfl), new File(target, cfl));- } catch (IOException e) {- e.printStackTrace();- }- }- } else {- target = new File(conf, cf);- target.getParentFile().mkdirs();- try {- Files.copy(source, target);- } catch (IOException e) {- e.printStackTrace();- }- }- }- String dir = corePath.getAbsolutePath();- File configFile = new File(solr_config, "solr.xml");- this.cores = new CoreContainer(dir, configFile); // this may take indefinitely long if solr files are broken- if (this.cores == null) throw new IOException("cannot create core container dir = " + dir + ", configFile = " + configFile);- this.defaultCoreName = this.cores.getDefaultCoreName();- Log.logInfo("SolrEmbeddedInstance", "detected default solr core: " + this.defaultCoreName);- this.defaultCore = this.cores.getCore(this.defaultCoreName); // should be "collection1"- if (this.defaultCore == null) {- // try again- Collection<SolrCore> cores = this.cores.getCores();- if (cores.size() > 0) {- this.defaultCore = cores.iterator().next();- this.defaultCoreName = this.defaultCore.getName();- }- }- if (this.defaultCore == null) {- throw new IOException("cannot get the default core; available = " + MemoryControl.available() + ", free = " + MemoryControl.free());- }- this.defaultServer = new EmbeddedSolrServer(this.cores, this.defaultCoreName);- }--- public File getStoragePath() {- return this.storagePath;- }-- @Override- public String getDefaultCoreName() {- return this.defaultCoreName;- }-- @Override- public Collection<String> getCoreNames() {- return this.cores.getCoreNames();- }-- @Override- public SolrServer getDefaultServer() {- return this.defaultServer;- }-- @Override- public SolrServer getServer(String name) {- return new EmbeddedSolrServer(this.cores, name);- }-- public SolrCore getDefaultCore() {- return this.defaultCore;- }-- public SolrCore getCore(String name) {- return this.cores.getCore(name);- }-- @Override- public synchronized void close() {- try {this.cores.shutdown();} catch (Throwable e) {Log.logException(e);}- }--}diff --git a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.javaindex f799a53ac..776894c67 100644--- a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java+++ b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java@@ -30,11 +30,11 @@ import java.util.Map;import java.util.Set;import java.util.regex.Pattern;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.protocol.HeaderFramework;import net.yacy.cora.util.CommonPattern;import net.yacy.peers.operation.yacyVersion;import net.yacy.search.Switchboard;+import net.yacy.search.schema.CollectionSchema;import org.apache.lucene.document.Document;import org.apache.lucene.index.IndexableField;@@ -83,16 +83,16 @@ public class GSAResponseWriter implements QueryResponseWriter {private static final Map<String, String> field2tag = new HashMap<String, String>();// pre-select a set of YaCy schema fields for the solr searcher which should cause a better caching- private static final YaCySchema[] extrafields = new YaCySchema[]{- YaCySchema.id, YaCySchema.sku, YaCySchema.title, YaCySchema.description,- YaCySchema.last_modified, YaCySchema.load_date_dt, YaCySchema.size_i, YaCySchema.language_s+ private static final CollectionSchema[] extrafields = new CollectionSchema[]{+ CollectionSchema.id, CollectionSchema.sku, CollectionSchema.title, CollectionSchema.description,+ CollectionSchema.last_modified, CollectionSchema.load_date_dt, CollectionSchema.size_i, CollectionSchema.language_s};private static final Set<String> SOLR_FIELDS = new HashSet<String>();static {- field2tag.put(YaCySchema.language_s.getSolrFieldName(), GSAToken.LANG.name());+ field2tag.put(CollectionSchema.language_s.getSolrFieldName(), GSAToken.LANG.name());SOLR_FIELDS.addAll(field2tag.keySet());- for (YaCySchema field: extrafields) SOLR_FIELDS.add(field.getSolrFieldName());+ for (CollectionSchema field: extrafields) SOLR_FIELDS.add(field.getSolrFieldName());}private static class ResHead {@@ -115,7 +115,7 @@ public class GSAResponseWriter implements QueryResponseWriter {}public String toSolr() {if (this.action != null && "date".equals(this.action)) {- return YaCySchema.last_modified.getSolrFieldName() + " " + (("D".equals(this.direction) ? "desc" : "asc"));+ return CollectionSchema.last_modified.getSolrFieldName() + " " + (("D".equals(this.direction) ? "desc" : "asc"));}return null;}@@ -221,7 +221,7 @@ public class GSAResponseWriter implements QueryResponseWriter {String mime = "";for (IndexableField value: fields) {String fieldName = value.name();- if (YaCySchema.content_type.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.content_type.getSolrFieldName().equals(fieldName)) {mime = value.stringValue();break;}@@ -244,40 +244,40 @@ public class GSAResponseWriter implements QueryResponseWriter {}// if the rule is not generic, use the specific here- if (YaCySchema.id.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.id.getSolrFieldName().equals(fieldName)) {urlhash = value.stringValue();continue;}- if (YaCySchema.sku.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.sku.getSolrFieldName().equals(fieldName)) {OpensearchResponseWriter.solitaireTag(writer, GSAToken.U.name(), value.stringValue());OpensearchResponseWriter.solitaireTag(writer, GSAToken.UE.name(), value.stringValue());continue;}- if (YaCySchema.title.getSolrFieldName().equals(fieldName) && !title_written) {+ if (CollectionSchema.title.getSolrFieldName().equals(fieldName) && !title_written) {OpensearchResponseWriter.solitaireTag(writer, GSAToken.T.name(), highlight(value.stringValue(), query));//texts.add(value.stringValue());title_written = true;continue;}- if (YaCySchema.description.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.description.getSolrFieldName().equals(fieldName)) {description = value.stringValue();//texts.add(description);continue;}- if (YaCySchema.last_modified.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.last_modified.getSolrFieldName().equals(fieldName)) {Date d = new Date(Long.parseLong(value.stringValue()));writer.write("<FS NAME=\"date\" VALUE=\"" + HeaderFramework.formatGSAFS(d) + "\"/>");//OpensearchResponseWriter.solitaireTag(writer, GSAToken.CACHE_LAST_MODIFIED.getSolrFieldName(), HeaderFramework.formatRFC1123(d));//texts.add(value.stringValue());continue;}- if (YaCySchema.load_date_dt.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.load_date_dt.getSolrFieldName().equals(fieldName)) {Date d = new Date(Long.parseLong(value.stringValue()));OpensearchResponseWriter.solitaireTag(writer, GSAToken.CRAWLDATE.name(), HeaderFramework.formatRFC1123(d));//texts.add(value.stringValue());continue;}- if (YaCySchema.size_i.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.size_i.getSolrFieldName().equals(fieldName)) {size = value.stringValue() != null && value.stringValue().length() > 0 ? Integer.parseInt(value.stringValue()) : -1;continue;}diff --git a/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.javaindex 73d28075c..7f3a2ca3a 100644--- a/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java+++ b/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java@@ -30,10 +30,10 @@ import java.util.List;import java.util.Map;import net.yacy.cora.document.MultiProtocolURI;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.solr.responsewriter.OpensearchResponseWriter.ResHead;import net.yacy.cora.protocol.HeaderFramework;import net.yacy.data.URLLicense;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import org.apache.lucene.document.Document;@@ -58,9 +58,9 @@ public class JsonResponseWriter implements QueryResponseWriter {// define a list of simple YaCySchema -> json Token matchingsprivate static final Map<String, String> field2tag = new HashMap<String, String>();static {- field2tag.put(YaCySchema.url_protocol_s.getSolrFieldName(), "protocol");- field2tag.put(YaCySchema.host_s.getSolrFieldName(), "host");- field2tag.put(YaCySchema.url_file_ext_s.getSolrFieldName(), "ext");+ field2tag.put(CollectionSchema.url_protocol_s.getSolrFieldName(), "protocol");+ field2tag.put(CollectionSchema.host_s.getSolrFieldName(), "host");+ field2tag.put(CollectionSchema.url_file_ext_s.getSolrFieldName(), "ext");}private String title;@@ -149,7 +149,7 @@ public class JsonResponseWriter implements QueryResponseWriter {}// some special handling here- if (YaCySchema.sku.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.sku.getSolrFieldName().equals(fieldName)) {String u = value.stringValue();try {url = new MultiProtocolURI(u);@@ -158,31 +158,31 @@ public class JsonResponseWriter implements QueryResponseWriter {} catch (MalformedURLException e) {}continue;}- if (YaCySchema.title.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.title.getSolrFieldName().equals(fieldName)) {title = value.stringValue();texts.add(title);continue;}- if (YaCySchema.description.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.description.getSolrFieldName().equals(fieldName)) {description = value.stringValue();texts.add(description);continue;}- if (YaCySchema.id.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.id.getSolrFieldName().equals(fieldName)) {urlhash = value.stringValue();solitaireTag(writer, "guid", urlhash);continue;}- if (YaCySchema.url_paths_sxt.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.url_paths_sxt.getSolrFieldName().equals(fieldName)) {path.append('/').append(value.stringValue());continue;}- if (YaCySchema.last_modified.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.last_modified.getSolrFieldName().equals(fieldName)) {Date d = new Date(Long.parseLong(value.stringValue()));solitaireTag(writer, "pubDate", HeaderFramework.formatRFC1123(d));continue;}- if (YaCySchema.size_i.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.size_i.getSolrFieldName().equals(fieldName)) {int size = value.stringValue() != null && value.stringValue().length() > 0 ? Integer.parseInt(value.stringValue()) : -1;int sizekb = size / 1024;int sizemb = sizekb / 1024;@@ -190,13 +190,13 @@ public class JsonResponseWriter implements QueryResponseWriter {solitaireTag(writer, "sizename", sizemb > 0 ? (Integer.toString(sizemb) + " mbyte") : sizekb > 0 ? (Integer.toString(sizekb) + " kbyte") : (Integer.toString(size) + " byte"));continue;}- if (YaCySchema.text_t.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.text_t.getSolrFieldName().equals(fieldName)) {texts.add(value.stringValue());continue;}- if (YaCySchema.h1_txt.getSolrFieldName().equals(fieldName) || YaCySchema.h2_txt.getSolrFieldName().equals(fieldName) ||- YaCySchema.h3_txt.getSolrFieldName().equals(fieldName) || YaCySchema.h4_txt.getSolrFieldName().equals(fieldName) ||- YaCySchema.h5_txt.getSolrFieldName().equals(fieldName) || YaCySchema.h6_txt.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.h1_txt.getSolrFieldName().equals(fieldName) || CollectionSchema.h2_txt.getSolrFieldName().equals(fieldName) ||+ CollectionSchema.h3_txt.getSolrFieldName().equals(fieldName) || CollectionSchema.h4_txt.getSolrFieldName().equals(fieldName) ||+ CollectionSchema.h5_txt.getSolrFieldName().equals(fieldName) || CollectionSchema.h6_txt.getSolrFieldName().equals(fieldName)) {// because these are multi-valued fields, there can be several of eachtexts.add(value.stringValue());continue;@@ -224,13 +224,13 @@ public class JsonResponseWriter implements QueryResponseWriter {// the facets can be created with the options &facet=true&facet.mincount=1&facet.field=host_s&facet.field=url_file_ext_s&facet.field=url_protocol_s&facet.field=author_sxt@SuppressWarnings("unchecked")- NamedList<Integer> domains = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.host_s.getSolrFieldName());+ NamedList<Integer> domains = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.host_s.getSolrFieldName());@SuppressWarnings("unchecked")- NamedList<Integer> filetypes = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.url_file_ext_s.getSolrFieldName());+ NamedList<Integer> filetypes = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.url_file_ext_s.getSolrFieldName());@SuppressWarnings("unchecked")- NamedList<Integer> protocols = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.url_protocol_s.getSolrFieldName());+ NamedList<Integer> protocols = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.url_protocol_s.getSolrFieldName());@SuppressWarnings("unchecked")- NamedList<Integer> authors = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.author_sxt.getSolrFieldName());+ NamedList<Integer> authors = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.author_sxt.getSolrFieldName());if (domains != null) {writer.write("{\"facetname\":\"domains\",\"displayname\":\"Domains\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray());diff --git a/source/net/yacy/cora/federate/solr/responsewriter/OpensearchResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/OpensearchResponseWriter.javaindex 1422a23ea..3fbb29b2e 100644--- a/source/net/yacy/cora/federate/solr/responsewriter/OpensearchResponseWriter.java+++ b/source/net/yacy/cora/federate/solr/responsewriter/OpensearchResponseWriter.java@@ -33,11 +33,11 @@ import java.util.Set;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.RSSMessage;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.lod.vocabulary.DublinCore;import net.yacy.cora.lod.vocabulary.Geo;import net.yacy.cora.lod.vocabulary.YaCyMetadata;import net.yacy.cora.protocol.HeaderFramework;+import net.yacy.search.schema.CollectionSchema;import org.apache.lucene.document.Document;import org.apache.lucene.index.IndexableField;@@ -58,18 +58,18 @@ public class OpensearchResponseWriter implements QueryResponseWriter {private static final Map<String, String> field2tag = new HashMap<String, String>();// pre-select a set of YaCy schema fields for the solr searcher which should cause a better caching- private static final YaCySchema[] extrafields = new YaCySchema[]{- YaCySchema.id, YaCySchema.title, YaCySchema.description, YaCySchema.text_t,- YaCySchema.h1_txt, YaCySchema.h2_txt, YaCySchema.h3_txt, YaCySchema.h4_txt, YaCySchema.h5_txt, YaCySchema.h6_txt,+ private static final CollectionSchema[] extrafields = new CollectionSchema[]{+ CollectionSchema.id, CollectionSchema.title, CollectionSchema.description, CollectionSchema.text_t,+ CollectionSchema.h1_txt, CollectionSchema.h2_txt, CollectionSchema.h3_txt, CollectionSchema.h4_txt, CollectionSchema.h5_txt, CollectionSchema.h6_txt,};static final Set<String> SOLR_FIELDS = new HashSet<String>();static {- field2tag.put(YaCySchema.coordinate_p.getSolrFieldName() + "_0_coordinate", Geo.Lat.getURIref());- field2tag.put(YaCySchema.coordinate_p.getSolrFieldName() + "_1_coordinate", Geo.Long.getURIref());- field2tag.put(YaCySchema.publisher_t.getSolrFieldName(), DublinCore.Publisher.getURIref());- field2tag.put(YaCySchema.author.getSolrFieldName(), DublinCore.Creator.getURIref());+ field2tag.put(CollectionSchema.coordinate_p.getSolrFieldName() + "_0_coordinate", Geo.Lat.getURIref());+ field2tag.put(CollectionSchema.coordinate_p.getSolrFieldName() + "_1_coordinate", Geo.Long.getURIref());+ field2tag.put(CollectionSchema.publisher_t.getSolrFieldName(), DublinCore.Publisher.getURIref());+ field2tag.put(CollectionSchema.author.getSolrFieldName(), DublinCore.Creator.getURIref());SOLR_FIELDS.addAll(field2tag.keySet());- for (YaCySchema field: extrafields) SOLR_FIELDS.add(field.getSolrFieldName());+ for (CollectionSchema field: extrafields) SOLR_FIELDS.add(field.getSolrFieldName());}private String title;@@ -176,7 +176,7 @@ public class OpensearchResponseWriter implements QueryResponseWriter {}// take apart the url- if (YaCySchema.sku.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.sku.getSolrFieldName().equals(fieldName)) {String u = value.stringValue();solitaireTag(writer, RSSMessage.Token.link.name(), u);try {@@ -189,40 +189,40 @@ public class OpensearchResponseWriter implements QueryResponseWriter {}// if the rule is not generic, use the specific here- if (YaCySchema.id.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.id.getSolrFieldName().equals(fieldName)) {urlhash = value.stringValue();solitaireTag(writer, RSSMessage.Token.guid.name(), urlhash, "isPermaLink=\"false\"");continue;}- if (YaCySchema.title.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.title.getSolrFieldName().equals(fieldName)) {title = value.stringValue();texts.add(title);continue;}- if (YaCySchema.last_modified.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.last_modified.getSolrFieldName().equals(fieldName)) {Date d = new Date(Long.parseLong(value.stringValue()));solitaireTag(writer, RSSMessage.Token.pubDate.name(), HeaderFramework.formatRFC1123(d));continue;}- if (YaCySchema.description.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.description.getSolrFieldName().equals(fieldName)) {description = value.stringValue();solitaireTag(writer, DublinCore.Description.getURIref(), description);texts.add(description);continue;}- if (YaCySchema.text_t.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.text_t.getSolrFieldName().equals(fieldName)) {texts.add(value.stringValue());continue;}- if (YaCySchema.size_i.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.size_i.getSolrFieldName().equals(fieldName)) {int size = value.numericValue().intValue();solitaireTag(writer, YaCyMetadata.size.getURIref(), Integer.toString(size));solitaireTag(writer, YaCyMetadata.sizename.getURIref(), RSSMessage.sizename(size));continue;}- if (YaCySchema.h1_txt.getSolrFieldName().equals(fieldName) || YaCySchema.h2_txt.getSolrFieldName().equals(fieldName) ||- YaCySchema.h3_txt.getSolrFieldName().equals(fieldName) || YaCySchema.h4_txt.getSolrFieldName().equals(fieldName) ||- YaCySchema.h5_txt.getSolrFieldName().equals(fieldName) || YaCySchema.h6_txt.getSolrFieldName().equals(fieldName)) {+ if (CollectionSchema.h1_txt.getSolrFieldName().equals(fieldName) || CollectionSchema.h2_txt.getSolrFieldName().equals(fieldName) ||+ CollectionSchema.h3_txt.getSolrFieldName().equals(fieldName) || CollectionSchema.h4_txt.getSolrFieldName().equals(fieldName) ||+ CollectionSchema.h5_txt.getSolrFieldName().equals(fieldName) || CollectionSchema.h6_txt.getSolrFieldName().equals(fieldName)) {// because these are multi-valued fields, there can be several of eachtexts.add(value.stringValue());continue;@@ -247,13 +247,13 @@ public class OpensearchResponseWriter implements QueryResponseWriter {// the facets can be created with the options &facet=true&facet.mincount=1&facet.field=host_s&facet.field=url_file_ext_s&facet.field=url_protocol_s&facet.field=author_sxt@SuppressWarnings("unchecked")- NamedList<Integer> domains = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.host_s.getSolrFieldName());+ NamedList<Integer> domains = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.host_s.getSolrFieldName());@SuppressWarnings("unchecked")- NamedList<Integer> filetypes = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.url_file_ext_s.getSolrFieldName());+ NamedList<Integer> filetypes = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.url_file_ext_s.getSolrFieldName());@SuppressWarnings("unchecked")- NamedList<Integer> protocols = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.url_protocol_s.getSolrFieldName());+ NamedList<Integer> protocols = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.url_protocol_s.getSolrFieldName());@SuppressWarnings("unchecked")- NamedList<Integer> authors = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.author_sxt.getSolrFieldName());+ NamedList<Integer> authors = facetFields == null ? null : (NamedList<Integer>) facetFields.get(CollectionSchema.author_sxt.getSolrFieldName());if (domains != null) {openTag(writer, "yacy:facet name=\"domains\" displayname=\"Domains\" type=\"String\" min=\"0\" max=\"0\" mean=\"0\"");diff --git a/source/net/yacy/crawler/data/CrawlQueues.java b/source/net/yacy/crawler/data/CrawlQueues.javaindex 2bfd10592..0c93b99cc 100644--- a/source/net/yacy/crawler/data/CrawlQueues.java+++ b/source/net/yacy/crawler/data/CrawlQueues.java@@ -84,8 +84,8 @@ public class CrawlQueues {this.log.logConfig("Starting Crawling Management");this.noticeURL = new NoticedURL(queuePath, sb.peers.myBotIDs(), sb.useTailCache, sb.exceed134217727);FileUtils.deletedelete(new File(queuePath, ERROR_DB_FILENAME));- this.errorURL = new ZURL(sb.index.fulltext().getSolr(), sb.index.fulltext().getSolrSchema(), queuePath, ERROR_DB_FILENAME, false, sb.useTailCache, sb.exceed134217727);- this.delegatedURL = new ZURL(sb.index.fulltext().getSolr(), sb.index.fulltext().getSolrSchema(), queuePath, DELEGATED_DB_FILENAME, true, sb.useTailCache, sb.exceed134217727);+ this.errorURL = new ZURL(sb.index.fulltext(), queuePath, ERROR_DB_FILENAME, false, sb.useTailCache, sb.exceed134217727);+ this.delegatedURL = new ZURL(sb.index.fulltext(), queuePath, DELEGATED_DB_FILENAME, true, sb.useTailCache, sb.exceed134217727);}public void relocate(final File newQueuePath) {@@ -96,8 +96,8 @@ public class CrawlQueues {this.noticeURL = new NoticedURL(newQueuePath, this.sb.peers.myBotIDs(), this.sb.useTailCache, this.sb.exceed134217727);FileUtils.deletedelete(new File(newQueuePath, ERROR_DB_FILENAME));- this.errorURL = new ZURL(this.sb.index.fulltext().getSolr(), this.sb.index.fulltext().getSolrSchema(), newQueuePath, ERROR_DB_FILENAME, false, this.sb.useTailCache, this.sb.exceed134217727);- this.delegatedURL = new ZURL(this.sb.index.fulltext().getSolr(), this.sb.index.fulltext().getSolrSchema(), newQueuePath, DELEGATED_DB_FILENAME, true, this.sb.useTailCache, this.sb.exceed134217727);+ this.errorURL = new ZURL(this.sb.index.fulltext(), newQueuePath, ERROR_DB_FILENAME, false, this.sb.useTailCache, this.sb.exceed134217727);+ this.delegatedURL = new ZURL(this.sb.index.fulltext(), newQueuePath, DELEGATED_DB_FILENAME, true, this.sb.useTailCache, this.sb.exceed134217727);}public synchronized void close() {diff --git a/source/net/yacy/crawler/data/ZURL.java b/source/net/yacy/crawler/data/ZURL.javaindex 7dc9b0526..5b805175d 100644--- a/source/net/yacy/crawler/data/ZURL.java+++ b/source/net/yacy/crawler/data/ZURL.java@@ -39,7 +39,6 @@ import org.apache.solr.common.SolrInputDocument;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.solr.FailType;-import net.yacy.cora.federate.solr.connector.SolrConnector;import net.yacy.cora.order.Base64Order;import net.yacy.cora.order.NaturalOrder;import net.yacy.cora.util.SpaceExceededException;@@ -52,7 +51,7 @@ import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.table.SplitTable;import net.yacy.kelondro.table.Table;import net.yacy.kelondro.util.FileUtils;-import net.yacy.search.index.SolrConfiguration;+import net.yacy.search.index.Fulltext;public class ZURL implements Iterable<ZURL.Entry> {@@ -92,19 +91,16 @@ public class ZURL implements Iterable<ZURL.Entry> {// the class objectprivate Index urlIndex;private final Queue<byte[]> stack;- private final SolrConnector solrConnector;- private final SolrConfiguration solrConfiguration;+ private final Fulltext fulltext;protected ZURL(- final SolrConnector solrConnector,- final SolrConfiguration solrConfiguration,+ final Fulltext fulltext,final File cachePath,final String tablename,final boolean startWithEmptyFile,final boolean useTailCache,final boolean exceed134217727) {- this.solrConnector = solrConnector;- this.solrConfiguration = solrConfiguration;+ this.fulltext = fulltext;// creates a new ZURL in a filecachePath.mkdirs();final File f = new File(cachePath, tablename);@@ -191,11 +187,11 @@ public class ZURL implements Iterable<ZURL.Entry> {put(entry);this.stack.add(entry.hash());if (!reason.startsWith("double")) log.logInfo(bentry.url().toNormalform(true) + " - " + reason);- if (this.solrConnector != null && failCategory.store) {+ if (this.fulltext.getDefaultConnector() != null && failCategory.store) {// send the error to solrtry {- SolrInputDocument errorDoc = this.solrConfiguration.err(bentry.url(), failCategory.name() + " " + reason, failCategory.failType, httpcode);- this.solrConnector.add(errorDoc);+ SolrInputDocument errorDoc = this.fulltext.getDefaultConfiguration().err(bentry.url(), failCategory.name() + " " + reason, failCategory.failType, httpcode);+ this.fulltext.getDefaultConnector().add(errorDoc);} catch (final IOException e) {Log.logWarning("SOLR", "failed to send error " + bentry.url().toNormalform(true) + " to solr: " + e.getMessage());}diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.javaindex befd65521..d67f90a8c 100644--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java@@ -36,7 +36,6 @@ import net.yacy.cora.date.MicroDate;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.solr.SolrType;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.lod.vocabulary.Tagging;import net.yacy.cora.order.Base64Order;import net.yacy.crawler.retrieval.Response;@@ -44,6 +43,7 @@ import net.yacy.document.Condenser;import net.yacy.kelondro.data.word.WordReference;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.Bitfield;+import net.yacy.search.schema.CollectionSchema;import net.yacy.utils.crypt;import org.apache.solr.client.solrj.util.ClientUtils;@@ -58,15 +58,15 @@ import org.apache.solr.common.SolrInputDocument;*/public class URIMetadataNode {- public static YaCySchema[] fieldList = new YaCySchema[]{- YaCySchema.audiolinkscount_i, YaCySchema.author, YaCySchema.collection_sxt, YaCySchema.content_type,- YaCySchema.coordinate_p, YaCySchema.description, YaCySchema.fresh_date_dt, YaCySchema.host_id_s, YaCySchema.id,- YaCySchema.imagescount_i, YaCySchema.inboundlinks_protocol_sxt, YaCySchema.inboundlinks_urlstub_txt,- YaCySchema.inboundlinkscount_i, YaCySchema.keywords, YaCySchema.language_s, YaCySchema.last_modified, YaCySchema.load_date_dt,- YaCySchema.md5_s, YaCySchema.outboundlinks_protocol_sxt, YaCySchema.outboundlinks_urlstub_txt,- YaCySchema.outboundlinkscount_i, YaCySchema.publisher_t, YaCySchema.referrer_id_txt, YaCySchema.size_i, YaCySchema.sku,- YaCySchema.text_t, YaCySchema.title, YaCySchema.title_words_val, YaCySchema.url_chars_i,- YaCySchema.videolinkscount_i, YaCySchema.videolinkscount_i, YaCySchema.wordcount_i};+ public static CollectionSchema[] fieldList = new CollectionSchema[]{+ CollectionSchema.audiolinkscount_i, CollectionSchema.author, CollectionSchema.collection_sxt, CollectionSchema.content_type,+ CollectionSchema.coordinate_p, CollectionSchema.description, CollectionSchema.fresh_date_dt, CollectionSchema.host_id_s, CollectionSchema.id,+ CollectionSchema.imagescount_i, CollectionSchema.inboundlinks_protocol_sxt, CollectionSchema.inboundlinks_urlstub_txt,+ CollectionSchema.inboundlinkscount_i, CollectionSchema.keywords, CollectionSchema.language_s, CollectionSchema.last_modified, CollectionSchema.load_date_dt,+ CollectionSchema.md5_s, CollectionSchema.outboundlinks_protocol_sxt, CollectionSchema.outboundlinks_urlstub_txt,+ CollectionSchema.outboundlinkscount_i, CollectionSchema.publisher_t, CollectionSchema.referrer_id_txt, CollectionSchema.size_i, CollectionSchema.sku,+ CollectionSchema.text_t, CollectionSchema.title, CollectionSchema.title_words_val, CollectionSchema.url_chars_i,+ CollectionSchema.videolinkscount_i, CollectionSchema.videolinkscount_i, CollectionSchema.wordcount_i};private byte[] hash = null;private String urlRaw = null, keywords = null;@@ -88,8 +88,8 @@ public class URIMetadataNode {this.snippet = "";this.word = null;this.ranking = Long.MIN_VALUE;- this.hash = ASCII.getBytes(getString(YaCySchema.id));- this.urlRaw = getString(YaCySchema.sku);+ this.hash = ASCII.getBytes(getString(CollectionSchema.id));+ this.urlRaw = getString(CollectionSchema.sku);try {this.url = new DigestURI(this.urlRaw, this.hash);} catch (MalformedURLException e) {@@ -119,13 +119,13 @@ public class URIMetadataNode {}public String hosthash() {- String hosthash = (String) this.doc.getFieldValue(YaCySchema.host_id_s.getSolrFieldName());+ String hosthash = (String) this.doc.getFieldValue(CollectionSchema.host_id_s.getSolrFieldName());if (hosthash == null) hosthash = ASCII.String(this.hash, 6, 6);return hosthash;}public Date moddate() {- return getDate(YaCySchema.last_modified);+ return getDate(CollectionSchema.last_modified);}public DigestURI url() {@@ -137,22 +137,22 @@ public class URIMetadataNode {}public String dc_title() {- ArrayList<String> a = getStringList(YaCySchema.title);+ ArrayList<String> a = getStringList(CollectionSchema.title);if (a == null || a.size() == 0) return "";return a.get(0);}public String dc_creator() {- return getString(YaCySchema.author);+ return getString(CollectionSchema.author);}public String dc_publisher() {- return getString(YaCySchema.publisher_t);+ return getString(CollectionSchema.publisher_t);}public String dc_subject() {if (this.keywords == null) {- this.keywords = getString(YaCySchema.keywords);+ this.keywords = getString(CollectionSchema.keywords);}return this.keywords;}@@ -161,7 +161,7 @@ public class URIMetadataNode {if (this.lat == Double.NaN) {this.lon = 0.0d;this.lat = 0.0d;- String latlon = (String) this.doc.getFieldValue(YaCySchema.coordinate_p.getSolrFieldName());+ String latlon = (String) this.doc.getFieldValue(CollectionSchema.coordinate_p.getSolrFieldName());if (latlon != null) {int p = latlon.indexOf(',');if (p > 0) {@@ -183,37 +183,37 @@ public class URIMetadataNode {}public Date loaddate() {- return getDate(YaCySchema.load_date_dt);+ return getDate(CollectionSchema.load_date_dt);}public Date freshdate() {- return getDate(YaCySchema.fresh_date_dt);+ return getDate(CollectionSchema.fresh_date_dt);}public String md5() {- return getString(YaCySchema.md5_s);+ return getString(CollectionSchema.md5_s);}public char doctype() {- ArrayList<String> a = getStringList(YaCySchema.content_type);+ ArrayList<String> a = getStringList(CollectionSchema.content_type);if (a == null || a.size() == 0) return Response.docType(url());return Response.docType(a.get(0));}public byte[] language() {- String language = getString(YaCySchema.language_s);+ String language = getString(CollectionSchema.language_s);if (language == null || language.length() == 0) return ASCII.getBytes("en");return UTF8.getBytes(language);}public byte[] referrerHash() {- ArrayList<String> referrer = getStringList(YaCySchema.referrer_id_txt);+ ArrayList<String> referrer = getStringList(CollectionSchema.referrer_id_txt);if (referrer == null || referrer.size() == 0) return null;return ASCII.getBytes(referrer.get(0));}public int size() {- return getInt(YaCySchema.size_i);+ return getInt(CollectionSchema.size_i);}public Bitfield flags() {@@ -230,41 +230,41 @@ public class URIMetadataNode {}public int wordCount() {- return getInt(YaCySchema.wordcount_i);+ return getInt(CollectionSchema.wordcount_i);}public int llocal() {- return getInt(YaCySchema.inboundlinkscount_i);+ return getInt(CollectionSchema.inboundlinkscount_i);}public int lother() {- return getInt(YaCySchema.outboundlinkscount_i);+ return getInt(CollectionSchema.outboundlinkscount_i);}public int limage() {if (this.imagec == -1) {- this.imagec = getInt(YaCySchema.imagescount_i);+ this.imagec = getInt(CollectionSchema.imagescount_i);}return this.imagec;}public int laudio() {if (this.audioc == -1) {- this.audioc = getInt(YaCySchema.audiolinkscount_i);+ this.audioc = getInt(CollectionSchema.audiolinkscount_i);}return this.audioc;}public int lvideo() {if (this.videoc == -1) {- this.videoc = getInt(YaCySchema.videolinkscount_i);+ this.videoc = getInt(CollectionSchema.videolinkscount_i);}return this.videoc;}public int lapp() {if (this.appc == -1) {- this.appc = getInt(YaCySchema.videolinkscount_i);+ this.appc = getInt(CollectionSchema.videolinkscount_i);}return this.appc;}@@ -274,13 +274,13 @@ public class URIMetadataNode {}public int wordsintitle() {- ArrayList<Integer> x = getIntList(YaCySchema.title_words_val);+ ArrayList<Integer> x = getIntList(CollectionSchema.title_words_val);if (x == null || x.size() == 0) return 0;return x.get(0).intValue();}public int urllength() {- return getInt(YaCySchema.url_chars_i);+ return getInt(CollectionSchema.url_chars_i);}public String snippet() {@@ -288,7 +288,7 @@ public class URIMetadataNode {}public String[] collections() {- ArrayList<String> a = getStringList(YaCySchema.collection_sxt);+ ArrayList<String> a = getStringList(CollectionSchema.collection_sxt);return a.toArray(new String[a.size()]);}@@ -305,8 +305,8 @@ public class URIMetadataNode {}public static Iterator<String> getLinks(SolrDocument doc, boolean inbound) {- Collection<Object> urlstub = doc.getFieldValues((inbound ? YaCySchema.inboundlinks_urlstub_txt : YaCySchema.outboundlinks_urlstub_txt).getSolrFieldName());- Collection<String> urlprot = urlstub == null ? null : indexedList2protocolList(doc.getFieldValues((inbound ? YaCySchema.inboundlinks_protocol_sxt : YaCySchema.outboundlinks_protocol_sxt).getSolrFieldName()), urlstub.size());+ Collection<Object> urlstub = doc.getFieldValues((inbound ? CollectionSchema.inboundlinks_urlstub_txt : CollectionSchema.outboundlinks_urlstub_txt).getSolrFieldName());+ Collection<String> urlprot = urlstub == null ? null : indexedList2protocolList(doc.getFieldValues((inbound ? CollectionSchema.inboundlinks_protocol_sxt : CollectionSchema.outboundlinks_protocol_sxt).getSolrFieldName()), urlstub.size());String u;LinkedHashSet<String> list = new LinkedHashSet<String>();if (urlprot != null && urlstub != null) {@@ -323,18 +323,18 @@ public class URIMetadataNode {return list.iterator();}- public static Date getDate(SolrDocument doc, final YaCySchema key) {+ public static Date getDate(SolrDocument doc, final CollectionSchema key) {Date x = doc == null ? null : (Date) doc.getFieldValue(key.getSolrFieldName());Date now = new Date();return (x == null) ? new Date(0) : x.after(now) ? now : x;}public String getText() {- return getString(YaCySchema.text_t);+ return getString(CollectionSchema.text_t);}public String getDescription() {- return getString(YaCySchema.description);+ return getString(CollectionSchema.description);}public boolean isOlder(URIMetadataRow other) {@@ -429,7 +429,7 @@ public class URIMetadataNode {return core.toString();}- private DigestURI getURL(YaCySchema field) {+ private DigestURI getURL(CollectionSchema field) {assert !field.isMultiValued();assert field.getType() == SolrType.string || field.getType() == SolrType.text_general || field.getType() == SolrType.text_en_splitting_tight;Object x = this.doc.getFieldValue(field.getSolrFieldName());@@ -441,7 +441,7 @@ public class URIMetadataNode {}}- private int getInt(YaCySchema field) {+ private int getInt(CollectionSchema field) {assert !field.isMultiValued();assert field.getType() == SolrType.num_integer;Object x = this.doc.getFieldValue(field.getSolrFieldName());@@ -451,7 +451,7 @@ public class URIMetadataNode {return 0;}- private Date getDate(YaCySchema field) {+ private Date getDate(CollectionSchema field) {assert !field.isMultiValued();assert field.getType() == SolrType.date;Date x = (Date) this.doc.getFieldValue(field.getSolrFieldName());@@ -460,7 +460,7 @@ public class URIMetadataNode {return x.after(now) ? now : x;}- private String getString(YaCySchema field) {+ private String getString(CollectionSchema field) {assert !field.isMultiValued();assert field.getType() == SolrType.string || field.getType() == SolrType.text_general || field.getType() == SolrType.text_en_splitting_tight;Object x = this.doc.getFieldValue(field.getSolrFieldName());@@ -474,7 +474,7 @@ public class URIMetadataNode {}@SuppressWarnings("unchecked")- private ArrayList<String> getStringList(YaCySchema field) {+ private ArrayList<String> getStringList(CollectionSchema field) {assert field.isMultiValued();assert field.getType() == SolrType.string || field.getType() == SolrType.text_general;Object r = this.doc.getFieldValue(field.getSolrFieldName());@@ -488,7 +488,7 @@ public class URIMetadataNode {}@SuppressWarnings("unchecked")- private ArrayList<Integer> getIntList(YaCySchema field) {+ private ArrayList<Integer> getIntList(CollectionSchema field) {assert field.isMultiValued();assert field.getType() == SolrType.num_integer;Object r = this.doc.getFieldValue(field.getSolrFieldName());diff --git a/source/net/yacy/migration.java b/source/net/yacy/migration.javaindex e7333246e..421ab6e4c 100644--- a/source/net/yacy/migration.java+++ b/source/net/yacy/migration.java@@ -279,12 +279,11 @@ public class migration {f.deleteOnExit();if (f.exists()) {return ret;- } else {- try {- f.createNewFile();- } catch (IOException ex) {- Log.logInfo("migrateUrldbtoSolr","could not create lock file");- }+ }+ try {+ f.createNewFile();+ } catch (IOException ex) {+ Log.logInfo("migrateUrldbtoSolr","could not create lock file");}final Thread t = new Thread() {diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.javaindex 38879bc8b..8660091e9 100644--- a/source/net/yacy/peers/Protocol.java+++ b/source/net/yacy/peers/Protocol.java@@ -69,10 +69,9 @@ import net.yacy.cora.document.RSSMessage;import net.yacy.cora.document.RSSReader;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.opensearch.SRURSSConnector;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.solr.connector.RemoteSolrConnector;import net.yacy.cora.federate.solr.connector.SolrConnector;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;+import net.yacy.cora.federate.solr.instance.RemoteInstance;import net.yacy.cora.federate.yacy.CacheStrategy;import net.yacy.cora.order.Base64Order;import net.yacy.cora.order.Digest;@@ -108,6 +107,7 @@ import net.yacy.search.SwitchboardConstants;import net.yacy.search.index.Segment;import net.yacy.search.query.SearchEvent;import net.yacy.search.query.SecondarySearchSuperviser;+import net.yacy.search.schema.CollectionSchema;import net.yacy.search.snippet.TextSnippet;import net.yacy.server.serverCore;import net.yacy.server.serverObjects;@@ -1007,7 +1007,7 @@ public final class Protocol {}}- private final static YaCySchema[] snippetFields = new YaCySchema[]{YaCySchema.h1_txt, YaCySchema.h2_txt, YaCySchema.text_t};+ private final static CollectionSchema[] snippetFields = new CollectionSchema[]{CollectionSchema.h1_txt, CollectionSchema.h2_txt, CollectionSchema.text_t};protected static int solrQuery(final SearchEvent event,@@ -1035,14 +1035,14 @@ public final class Protocol {solrQuery.setFacet(false);}- // set highlightning query attributes+ // set highlighting query attributessolrQuery.setHighlight(true);solrQuery.setHighlightFragsize(SearchEvent.SNIPPET_MAX_LENGTH);//solrQuery.setHighlightRequireFieldMatch();solrQuery.setHighlightSimplePost("</b>");solrQuery.setHighlightSimplePre("<b>");solrQuery.setHighlightSnippets(1);- for (YaCySchema field: snippetFields) solrQuery.addHighlightField(field.getSolrFieldName());+ for (CollectionSchema field: snippetFields) solrQuery.addHighlightField(field.getSolrFieldName());boolean localsearch = target == null || target.equals(event.peers.mySeed());SolrDocumentList docList = null;@@ -1050,16 +1050,15 @@ public final class Protocol {if (localsearch) {// search the local indextry {- rsp = event.rankingProcess.getQuery().getSegment().fulltext().getSolr().query(solrQuery);+ rsp = event.rankingProcess.getQuery().getSegment().fulltext().getDefaultConnector().query(solrQuery);docList = rsp.getResults();} catch (Throwable e) {Network.log.logInfo("SEARCH failed (solr), localpeer (" + e.getMessage() + ")", e);return -1;}} else {- final String solrURL = "http://" + target.getPublicAddress() + "/solr";try {- SolrRemoteInstance instance = new SolrRemoteInstance(solrURL);+ RemoteInstance instance = new RemoteInstance("http://" + target.getPublicAddress(), null, "solr"); // this is a 'patch configuration' which considers 'solr' as default collectionSolrConnector solrConnector = new RemoteSolrConnector(instance, "solr");rsp = solrConnector.query(solrQuery);docList = rsp.getResults();@@ -1093,7 +1092,7 @@ public final class Protocol {if (rawsnippets != null) {nextsnippet: for (Map.Entry<String, Map<String, List<String>>> re: rawsnippets.entrySet()) {Map<String, List<String>> rs = re.getValue();- for (YaCySchema field: snippetFields) {+ for (CollectionSchema field: snippetFields) {if (rs.containsKey(field.getSolrFieldName())) {List<String> s = rs.get(field.getSolrFieldName());if (s.size() > 0) {@@ -1151,7 +1150,7 @@ public final class Protocol {// passed all checks, store urlif (!localsearch) {try {- event.query.getSegment().fulltext().putDocument(event.query.getSegment().fulltext().getSolrSchema().toSolrInputDocument(doc));+ event.query.getSegment().fulltext().putDocument(event.query.getSegment().fulltext().getDefaultConfiguration().toSolrInputDocument(doc));ResultURLs.stack(ASCII.String(urlEntry.url().hash()),urlEntry.url().getHost(),diff --git a/source/net/yacy/peers/RemoteSearch.java b/source/net/yacy/peers/RemoteSearch.javaindex 2574f84de..1d98d80ee 100644--- a/source/net/yacy/peers/RemoteSearch.java+++ b/source/net/yacy/peers/RemoteSearch.java@@ -161,6 +161,9 @@ public class RemoteSearch extends Thread {nodePeers.add(s);}}++ // for debugging: remove all dht peer to see if solr is working properly+ //dhtPeers.clear(); // FOR DEBUGGING ONLY!!!// start solr searchesfor (Seed s: nodePeers) {diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex c99d43681..575889858 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -97,15 +97,12 @@ import net.yacy.cora.document.UTF8;import net.yacy.cora.document.WordCache;import net.yacy.cora.document.analysis.Classification;import net.yacy.cora.federate.solr.Boost;+import net.yacy.cora.federate.solr.SchemaConfiguration;import net.yacy.cora.federate.solr.ProcessType;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.solr.connector.AbstractSolrConnector;-import net.yacy.cora.federate.solr.connector.ShardSelection;import net.yacy.cora.federate.solr.connector.ShardSolrConnector;-import net.yacy.cora.federate.solr.connector.SolrConnector;-import net.yacy.cora.federate.solr.instance.SolrRemoteInstance;+import net.yacy.cora.federate.solr.instance.RemoteInstance;import net.yacy.cora.federate.yacy.CacheStrategy;-import net.yacy.cora.federate.yacy.ConfigurationSet;import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.order.Base64Order;import net.yacy.cora.order.Digest;@@ -190,12 +187,14 @@ import net.yacy.repository.Blacklist.BlacklistType;import net.yacy.repository.FilterEngine;import net.yacy.repository.LoaderDispatcher;import net.yacy.search.index.Segment;-import net.yacy.search.index.SolrConfiguration;import net.yacy.search.query.AccessTracker;import net.yacy.search.query.SearchEvent;import net.yacy.search.query.SearchEventCache;import net.yacy.search.ranking.BlockRank;import net.yacy.search.ranking.RankingProfile;+import net.yacy.search.schema.CollectionConfiguration;+import net.yacy.search.schema.CollectionSchema;+import net.yacy.search.schema.WebgraphConfiguration;import net.yacy.search.snippet.TextSnippet;import net.yacy.server.serverCore;import net.yacy.server.serverSwitch;@@ -209,6 +208,10 @@ import com.google.common.io.Files;public final class Switchboard extends serverSwitch {+ final static String SOLR_COLLECTION_CONFIGURATION_NAME_OLD = "solr.keys.default.list";+ final static String SOLR_COLLECTION_CONFIGURATION_NAME = "solr.collection.schema";+ final static String SOLR_WEBGRAPH_CONFIGURATION_NAME = "solr.webgraph.schema";+// load slotspublic static int xstackCrawlSlots = 2000;public static long lastPPMUpdate = System.currentTimeMillis() - 30000;@@ -397,38 +400,55 @@ public final class Switchboard extends serverSwitch {this.networkRoot.mkdirs();this.queuesRoot.mkdirs();+ // define boosts+ Boost.RANKING.updateBoosts(this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_BOOST, "")); // must be called every time the boosts change+ Boost.RANKING.setMinTokenLen(this.getConfigInt(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_MINLENGTH, 3));+ Boost.RANKING.setQuantRate(this.getConfigFloat(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_QUANTRATE, 0.5f));+// prepare a solr index profile switch list- final File solrBackupProfile = new File("defaults/solr.keys.list");- final String schemename = getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE, "solr.keys.default.list");- final File solrWorkProfile = new File(getDataPath(), "DATA/SETTINGS/" + schemename);- if ( !solrWorkProfile.exists() ) {- Files.copy(solrBackupProfile, solrWorkProfile);- }+ final File solrCollectionConfigurationInitFile = new File(getAppPath(), "defaults/" + SOLR_COLLECTION_CONFIGURATION_NAME);+ final File solrCollectionConfigurationWorkFile = new File(getDataPath(), "DATA/SETTINGS/" + SOLR_COLLECTION_CONFIGURATION_NAME);+ final File solrWebgraphConfigurationInitFile = new File(getAppPath(), "defaults/" + SOLR_WEBGRAPH_CONFIGURATION_NAME);+ final File solrWebgraphConfigurationWorkFile = new File(getDataPath(), "DATA/SETTINGS/" + SOLR_WEBGRAPH_CONFIGURATION_NAME);++ // migrate the old Schema file path to a new one+ final File solrCollectionConfigurationWorkOldFile = new File(getDataPath(), "DATA/SETTINGS/" + SOLR_COLLECTION_CONFIGURATION_NAME_OLD);+ if (solrCollectionConfigurationWorkOldFile.exists() && !solrCollectionConfigurationWorkFile.exists()) solrCollectionConfigurationWorkOldFile.renameTo(solrCollectionConfigurationWorkFile);++ // initialize the schema if it does not yet exist+ if (!solrCollectionConfigurationWorkFile.exists()) Files.copy(solrCollectionConfigurationInitFile, solrCollectionConfigurationWorkFile);++ // lazy definition of schema: do not write empty fieldsfinal boolean solrlazy = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, true);- final SolrConfiguration backupScheme = new SolrConfiguration(solrBackupProfile, solrlazy);- final SolrConfiguration solrScheme = new SolrConfiguration(solrWorkProfile, solrlazy);++ // define collection schema+ final CollectionConfiguration solrCollectionConfigurationInit = new CollectionConfiguration(solrCollectionConfigurationInitFile, solrlazy);+ final CollectionConfiguration solrCollectionConfigurationWork = new CollectionConfiguration(solrCollectionConfigurationWorkFile, solrlazy);// update the working scheme with the backup scheme. This is necessary to include new features.// new features are always activated by default (if activated in input-backupScheme)- solrScheme.fill(backupScheme, true);+ solrCollectionConfigurationWork.fill(solrCollectionConfigurationInit, true);// switch on some fields which are necessary for ranking and faceting- for (YaCySchema field: new YaCySchema[]{- YaCySchema.host_s, YaCySchema.load_date_dt,- YaCySchema.url_file_ext_s, YaCySchema.last_modified, // needed for media search and /date operator- /*YaCySchema.url_paths_sxt,*/ YaCySchema.host_organization_s, // needed to search in the url- /*YaCySchema.inboundlinks_protocol_sxt,*/ YaCySchema.inboundlinks_urlstub_txt, // needed for HostBrowser- /*YaCySchema.outboundlinks_protocol_sxt,*/ YaCySchema.outboundlinks_urlstub_txt // needed to enhance the crawler+ for (CollectionSchema field: new CollectionSchema[]{+ CollectionSchema.host_s, CollectionSchema.load_date_dt,+ CollectionSchema.url_file_ext_s, CollectionSchema.last_modified, // needed for media search and /date operator+ /*YaCySchema.url_paths_sxt,*/ CollectionSchema.host_organization_s, // needed to search in the url+ /*YaCySchema.inboundlinks_protocol_sxt,*/ CollectionSchema.inboundlinks_urlstub_txt, // needed for HostBrowser+ /*YaCySchema.outboundlinks_protocol_sxt,*/ CollectionSchema.outboundlinks_urlstub_txt // needed to enhance the crawler}) {- ConfigurationSet.Entry entry = solrScheme.get(field.name()); entry.setEnable(true); solrScheme.put(field.name(), entry);+ SchemaConfiguration.Entry entry = solrCollectionConfigurationWork.get(field.name()); entry.setEnable(true); solrCollectionConfigurationWork.put(field.name(), entry);}- solrScheme.commit();- Boost.RANKING.updateBoosts(this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_BOOST, "")); // must be called every time the boosts change- Boost.RANKING.setMinTokenLen(this.getConfigInt(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_MINLENGTH, 3));- Boost.RANKING.setQuantRate(this.getConfigFloat(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_QUANTRATE, 0.5f));+ solrCollectionConfigurationWork.commit();++ // define webgraph schema+ final WebgraphConfiguration solrWebgraphConfigurationInit = new WebgraphConfiguration(solrWebgraphConfigurationInitFile, solrlazy);+ final WebgraphConfiguration solrWebgraphConfigurationWork = new WebgraphConfiguration(solrWebgraphConfigurationWorkFile, solrlazy);+ solrWebgraphConfigurationWork.fill(solrWebgraphConfigurationInit, true);+ solrWebgraphConfigurationWork.commit();// initialize indexReferenceContainer.maxReferences = getConfigInt("index.maxReferences", 0);final File segmentsPath = new File(new File(indexPath, networkName), "SEGMENTS");- this.index = new Segment(this.log, new File(segmentsPath, "default"), solrScheme);+ this.index = new Segment(this.log, segmentsPath, solrCollectionConfigurationWork, solrWebgraphConfigurationWork);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_RWI, true)) this.index.connectRWI(wordCacheMaxCount, fileSizeMax);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_CITATION, true)) this.index.connectCitation(wordCacheMaxCount, fileSizeMax);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_FULLTEXT, true)) {@@ -442,9 +462,8 @@ public final class Switchboard extends serverSwitch {if (usesolr && solrurls != null && solrurls.length() > 0) {try {- ArrayList<SolrRemoteInstance> instances = ShardSolrConnector.getShardInstances(solrurls);- ShardSolrConnector solr = new ShardSolrConnector(instances, ShardSelection.Method.MODULO_HOST_MD5, true);- this.index.fulltext().connectRemoteSolr(solr);+ ArrayList<RemoteInstance> instances = ShardSolrConnector.getShardInstances(solrurls, null, null);+ this.index.fulltext().connectRemoteSolr(instances);} catch ( final IOException e ) {Log.logException(e);}@@ -1230,7 +1249,8 @@ public final class Switchboard extends serverSwitch {synchronized ( this ) {// remember the solr scheme- SolrConfiguration solrScheme = this.index.fulltext().getSolrSchema();+ CollectionConfiguration collectionConfiguration = this.index.fulltext().getDefaultConfiguration();+ WebgraphConfiguration webgraphConfiguration = this.index.fulltext().getWebgraphConfiguration();// shut downthis.crawler.close();@@ -1278,7 +1298,7 @@ public final class Switchboard extends serverSwitch {partitionExponent,this.useTailCache,this.exceed134217727);- this.index = new Segment(this.log, new File(new File(new File(indexPrimaryPath, networkName), "SEGMENTS"), "default"), solrScheme);+ this.index = new Segment(this.log, new File(new File(indexPrimaryPath, networkName), "SEGMENTS"), collectionConfiguration, webgraphConfiguration);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_RWI, true)) this.index.connectRWI(wordCacheMaxCount, fileSizeMax);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_CITATION, true)) this.index.connectCitation(wordCacheMaxCount, fileSizeMax);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_FULLTEXT, true)) {@@ -1292,9 +1312,8 @@ public final class Switchboard extends serverSwitch {if (usesolr && solrurls != null && solrurls.length() > 0) {try {- ArrayList<SolrRemoteInstance> instances = ShardSolrConnector.getShardInstances(solrurls);- ShardSolrConnector solr = new ShardSolrConnector(instances, ShardSelection.Method.MODULO_HOST_MD5, true);- this.index.fulltext().connectRemoteSolr(solr);+ ArrayList<RemoteInstance> instances = ShardSolrConnector.getShardInstances(solrurls, null, null);+ this.index.fulltext().connectRemoteSolr(instances);} catch ( final IOException e ) {Log.logException(e);}@@ -2217,11 +2236,11 @@ public final class Switchboard extends serverSwitch {// if no crawl is running and processing is activated:// execute the (post-) processing steps for all entries that have a process tag assigned- if (this.crawlQueues.coreCrawlJobSize() == 0 && index.connectedCitation() && index.fulltext().getSolrSchema().contains(YaCySchema.process_sxt)) {+ if (this.crawlQueues.coreCrawlJobSize() == 0 && index.connectedCitation() && index.fulltext().getDefaultConfiguration().contains(CollectionSchema.process_sxt)) {// that means we must search for those entries.- index.fulltext().getSolr().commit(true); // make sure that we have latest information that can be found+ index.fulltext().getDefaultConnector().commit(true); // make sure that we have latest information that can be found//BlockingQueue<SolrDocument> docs = index.fulltext().getSolr().concurrentQuery("*:*", 0, 1000, 60000, 10);- BlockingQueue<SolrDocument> docs = index.fulltext().getSolr().concurrentQuery(YaCySchema.process_sxt.getSolrFieldName() + ":[* TO *]", 0, 1000, 60000, 10);+ BlockingQueue<SolrDocument> docs = index.fulltext().getDefaultConnector().concurrentQuery(CollectionSchema.process_sxt.getSolrFieldName() + ":[* TO *]", 0, 1000, 60000, 10);SolrDocument doc;int proccount_clickdepth = 0;@@ -2229,7 +2248,7 @@ public final class Switchboard extends serverSwitch {int proccount_referencechange = 0;while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {// for each to-be-processed entry work on the process tag- Collection<Object> proctags = doc.getFieldValues(YaCySchema.process_sxt.getSolrFieldName());+ Collection<Object> proctags = doc.getFieldValues(CollectionSchema.process_sxt.getSolrFieldName());for (Object tag: proctags) {String tagname = (String) tag;ProcessType tagtype = ProcessType.valueOf(tagname);@@ -2237,32 +2256,32 @@ public final class Switchboard extends serverSwitch {// switch over tag typesif (tagtype == ProcessType.CLICKDEPTH) {//proctags.remove(tag);- if (index.fulltext().getSolrSchema().contains(YaCySchema.clickdepth_i)) {+ if (index.fulltext().getDefaultConfiguration().contains(CollectionSchema.clickdepth_i)) {DigestURI url;try {// get new click depth and compare with old- Integer oldclickdepth = (Integer) doc.getFieldValue(YaCySchema.clickdepth_i.getSolrFieldName());- url = new DigestURI((String) doc.getFieldValue(YaCySchema.sku.getSolrFieldName()), ASCII.getBytes((String) doc.getFieldValue(YaCySchema.id.getSolrFieldName())));- int clickdepth = SolrConfiguration.getClickDepth(index.urlCitation(), url);+ Integer oldclickdepth = (Integer) doc.getFieldValue(CollectionSchema.clickdepth_i.getSolrFieldName());+ url = new DigestURI((String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName()), ASCII.getBytes((String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName())));+ int clickdepth = CollectionConfiguration.getClickDepth(index.urlCitation(), url);if (oldclickdepth == null || oldclickdepth.intValue() != clickdepth) proccount_clickdepthchange++;- SolrInputDocument sid = index.fulltext().getSolrSchema().toSolrInputDocument(doc);- sid.setField(YaCySchema.clickdepth_i.getSolrFieldName(), clickdepth);+ SolrInputDocument sid = index.fulltext().getDefaultConfiguration().toSolrInputDocument(doc);+ sid.setField(CollectionSchema.clickdepth_i.getSolrFieldName(), clickdepth);// refresh the link count; it's 'cheap' to do this here- if (index.fulltext().getSolrSchema().contains(YaCySchema.references_i)) {- Integer oldreferences = (Integer) doc.getFieldValue(YaCySchema.references_i.getSolrFieldName());+ if (index.fulltext().getDefaultConfiguration().contains(CollectionSchema.references_i)) {+ Integer oldreferences = (Integer) doc.getFieldValue(CollectionSchema.references_i.getSolrFieldName());int references = index.urlCitation().count(url.hash());if (references > 0) {if (oldreferences == null || oldreferences.intValue() != references) proccount_referencechange++;- sid.setField(YaCySchema.references_i.getSolrFieldName(), references);+ sid.setField(CollectionSchema.references_i.getSolrFieldName(), references);}}// remove the processing tag- sid.removeField(YaCySchema.process_sxt.getSolrFieldName());+ sid.removeField(CollectionSchema.process_sxt.getSolrFieldName());// send back to index- index.fulltext().getSolr().add(sid);+ index.fulltext().getDefaultConnector().add(sid);proccount_clickdepth++;} catch (Throwable e) {Log.logException(e);diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.javaindex fbba77be0..33fc1aa8d 100644--- a/source/net/yacy/search/SwitchboardConstants.java+++ b/source/net/yacy/search/SwitchboardConstants.java@@ -295,7 +295,6 @@ public final class SwitchboardConstants {public static final String FEDERATED_SERVICE_SOLR_INDEXING_ENABLED = "federated.service.solr.indexing.enabled";public static final String FEDERATED_SERVICE_SOLR_INDEXING_URL = "federated.service.solr.indexing.url";public static final String FEDERATED_SERVICE_SOLR_INDEXING_SHARDING = "federated.service.solr.indexing.sharding";- public static final String FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE = "federated.service.solr.indexing.schemefile";public static final String FEDERATED_SERVICE_SOLR_INDEXING_LAZY = "federated.service.solr.indexing.lazy";//public static final String CORE_SERVICE_URLDB = "core.service.urldb.tmp";diff --git a/source/net/yacy/search/index/DocumentIndex.java b/source/net/yacy/search/index/DocumentIndex.javaindex e22bfa71c..c08ff366f 100644--- a/source/net/yacy/search/index/DocumentIndex.java+++ b/source/net/yacy/search/index/DocumentIndex.java@@ -40,6 +40,8 @@ import net.yacy.document.LibraryProvider;import net.yacy.document.TextParser;import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;+import net.yacy.search.schema.CollectionConfiguration;+import net.yacy.search.schema.WebgraphConfiguration;/*** convenience class to access the yacycore library from outside of yacy to put files into the index@@ -61,9 +63,12 @@ public class DocumentIndex extends Segment {static final ThreadGroup workerThreadGroup = new ThreadGroup("workerThreadGroup");- public DocumentIndex(final File segmentPath, final File schemaPath, final CallbackListener callback, final int cachesize)+ public DocumentIndex(final File segmentPath, final File collectionConfigurationPath, final File webgraphConfigurationPath, final CallbackListener callback, final int cachesize)throws IOException {- super(new Log("DocumentIndex"), segmentPath, schemaPath == null ? null : new SolrConfiguration(schemaPath, true));+ super(new Log("DocumentIndex"), segmentPath,+ collectionConfigurationPath == null ? null : new CollectionConfiguration(collectionConfigurationPath, true),+ webgraphConfigurationPath == null ? null : new WebgraphConfiguration(webgraphConfigurationPath, true)+ );super.connectRWI(cachesize, targetFileSize * 4 - 1);super.connectCitation(cachesize, targetFileSize * 4 - 1);super.connectUrlDb(diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.javaindex 953d8d5ba..65342c7f3 100644--- a/source/net/yacy/search/index/Fulltext.java+++ b/source/net/yacy/search/index/Fulltext.java@@ -41,13 +41,16 @@ import net.yacy.cora.date.GenericFormatter;import net.yacy.cora.date.ISO8601Formatter;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.MultiProtocolURI;-import net.yacy.cora.federate.solr.YaCySchema;+import net.yacy.cora.federate.solr.SchemaConfiguration;import net.yacy.cora.federate.solr.connector.AbstractSolrConnector;import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;-import net.yacy.cora.federate.solr.connector.MirrorSolrConnector;-import net.yacy.cora.federate.solr.connector.ShardSolrConnector;+import net.yacy.cora.federate.solr.connector.RemoteSolrConnector;+import net.yacy.cora.federate.solr.connector.ShardSelection;import net.yacy.cora.federate.solr.connector.SolrConnector;-import net.yacy.cora.federate.solr.instance.SolrEmbeddedInstance;+import net.yacy.cora.federate.solr.instance.EmbeddedInstance;+import net.yacy.cora.federate.solr.instance.InstanceMirror;+import net.yacy.cora.federate.solr.instance.RemoteInstance;+import net.yacy.cora.federate.solr.instance.ShardInstance;import net.yacy.cora.order.CloneableIterator;import net.yacy.cora.sorting.ReversibleScoreMap;import net.yacy.cora.sorting.ScoreMap;@@ -65,12 +68,17 @@ import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.table.SplitTable;import net.yacy.kelondro.util.MemoryControl;import net.yacy.search.Switchboard;+import net.yacy.search.schema.CollectionConfiguration;+import net.yacy.search.schema.CollectionSchema;+import net.yacy.search.schema.WebgraphConfiguration;+import net.yacy.search.schema.WebgraphSchema;import org.apache.commons.httpclient.util.DateUtil;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.lucene.util.Version;+import org.apache.solr.core.CoreContainer;public final class Fulltext {@@ -78,22 +86,24 @@ public final class Fulltext {private static final String SOLR_OLD_PATH[] = new String[]{"solr_36"};// class objects- private final File location;- private Index urlIndexFile;- private Export exportthread; // will have a export thread assigned if exporter is running- private String tablename;- private ArrayList<HostStat> statsDump;- private final MirrorSolrConnector solr;- private final SolrConfiguration solrSchema;-- protected Fulltext(final File path, final SolrConfiguration solrSchema) {- this.location = path;+ private final File segmentPath;+ private Index urlIndexFile;+ private Export exportthread; // will have a export thread assigned if exporter is running+ private String tablename;+ private ArrayList<HostStat> statsDump;+ private InstanceMirror solrInstances;+ private final CollectionConfiguration collectionConfiguration;+ private final WebgraphConfiguration webgraphConfiguration;++ protected Fulltext(final File segmentPath, final CollectionConfiguration collectionConfiguration, final WebgraphConfiguration webgraphConfiguration) {+ this.segmentPath = segmentPath;this.tablename = null;this.urlIndexFile = null;this.exportthread = null; // will have a export thread assigned if exporter is runningthis.statsDump = null;- this.solr = new MirrorSolrConnector(10000, 10000, 100);- this.solrSchema = solrSchema;+ this.solrInstances = new InstanceMirror();+ this.collectionConfiguration = collectionConfiguration;+ this.webgraphConfiguration = webgraphConfiguration;}/**@@ -121,7 +131,7 @@ public final class Fulltext {protected void connectUrlDb(final String tablename, final boolean useTailCache, final boolean exceed134217727) {if (this.urlIndexFile != null) return;this.tablename = tablename;- this.urlIndexFile = new SplitTable(this.location, tablename, URIMetadataRow.rowdef, useTailCache, exceed134217727);+ this.urlIndexFile = new SplitTable(new File(this.segmentPath, "default"), tablename, URIMetadataRow.rowdef, useTailCache, exceed134217727);// SplitTable always returns != null, even if no file exists.// as old UrlDb should be null if not exist, check and close if empty// TODO: check if a SplitTable.open() returning null or error status on not existing file is preferable@@ -136,91 +146,118 @@ public final class Fulltext {this.urlIndexFile = null;}- public SolrConfiguration getSolrSchema() {- return this.solrSchema;+ public CollectionConfiguration getDefaultConfiguration() {+ return this.collectionConfiguration;+ }++ public WebgraphConfiguration getWebgraphConfiguration() {+ return this.webgraphConfiguration;}public boolean connectedLocalSolr() {- return this.solr.isConnected0();+ return this.solrInstances.isConnected0();}public void connectLocalSolr() throws IOException {- File baseLocation = this.location;- if (baseLocation.getName().equals("default")) baseLocation = baseLocation.getParentFile();- File solrLocation = new File(baseLocation, SOLR_PATH);+ File solrLocation = new File(this.segmentPath, SOLR_PATH);// migrate old solr to newfor (String oldVersion: SOLR_OLD_PATH) {- File oldLocation = new File(baseLocation, oldVersion);+ File oldLocation = new File(this.segmentPath, oldVersion);if (oldLocation.exists()) oldLocation.renameTo(solrLocation);}- SolrEmbeddedInstance instance = new SolrEmbeddedInstance(solrLocation, new File(new File(Switchboard.getSwitchboard().appPath, "defaults"), "solr"));- EmbeddedSolrConnector esc = new EmbeddedSolrConnector(instance);- Version luceneVersion = esc.getConfig().getLuceneVersion("luceneMatchVersion");+ assert CoreContainer.DEFAULT_DEFAULT_CORE_NAME.equals(CollectionSchema.CORE_NAME); // check that solr and we use the same default core name++ EmbeddedInstance localCollectionInstance = new EmbeddedInstance(new File(new File(Switchboard.getSwitchboard().appPath, "defaults"), "solr"), solrLocation, CollectionSchema.CORE_NAME, new String[]{CollectionSchema.CORE_NAME, WebgraphSchema.CORE_NAME});+ EmbeddedSolrConnector localCollectionConnector = new EmbeddedSolrConnector(localCollectionInstance);++ Version luceneVersion = localCollectionConnector.getConfig().getLuceneVersion("luceneMatchVersion");String lvn = luceneVersion.name();Log.logInfo("Fulltext", "using lucene version " + lvn);int p = lvn.indexOf('_');assert SOLR_PATH.endsWith(lvn.substring(p)) : "luceneVersion = " + lvn + ", solrPath = " + SOLR_PATH + ", p = " + p + ", check defaults/solr/solrconfig.xml";- Log.logInfo("Fulltext", "connected solr in " + solrLocation.toString() + ", lucene version " + lvn);- this.solr.connect0(esc);+ Log.logInfo("Fulltext", "connected solr in " + solrLocation.toString() + ", lucene version " + lvn + ", default core size: " + localCollectionConnector.getSize());+ this.solrInstances.connect0(localCollectionInstance);}public void disconnectLocalSolr() {- this.solr.disconnect0();+ this.solrInstances.disconnect0();}public boolean connectedRemoteSolr() {- return this.solr.isConnected1();+ return this.solrInstances.isConnected1();}- public void connectRemoteSolr(final ShardSolrConnector rs) {- this.solr.connect1(rs);+ public void connectRemoteSolr(final ArrayList<RemoteInstance> instances) {+ this.solrInstances.connect1(new ShardInstance(instances, ShardSelection.Method.MODULO_HOST_MD5));}public void disconnectRemoteSolr() {- this.solr.disconnect1();+ this.solrInstances.disconnect1();}- public SolrConnector getLocalSolr() {- return this.solr.getSolr0();+ public EmbeddedSolrConnector getDefaultLocalSolrConnector() {+ if (this.solrInstances.getSolr0() == null) return null;+ return new EmbeddedSolrConnector(this.solrInstances.getSolr0());}- public SolrConnector getRemoteSolr() {- return this.solr.getSolr1();+ public RemoteSolrConnector getDefaultRemoteSolrConnector() {+ if (this.solrInstances.getSolr1() == null) return null;+ try {+ return new RemoteSolrConnector(this.solrInstances.getSolr1());+ } catch (IOException e) {+ return null;+ }}-- public SolrConnector getSolr() {- return this.solr;++ public SolrConnector getDefaultConnector() {+ return this.solrInstances.getDefaultConnector();+ }++ public SolrConnector getWebgraphConnector() {+ return this.solrInstances.getConnector(WebgraphSchema.CORE_NAME);}public void clearCache() {if (this.urlIndexFile != null && this.urlIndexFile instanceof Cache) ((Cache) this.urlIndexFile).clearCache();if (this.statsDump != null) this.statsDump.clear();+ this.solrInstances.clearCache();this.statsDump = null;- this.solr.clearCache();}public void clearURLIndex() throws IOException {if (this.exportthread != null) this.exportthread.interrupt();if (this.urlIndexFile == null) {- SplitTable.delete(this.location, this.tablename);+ SplitTable.delete(new File(this.segmentPath, "default"), this.tablename);} else {this.urlIndexFile.clear();}this.statsDump = null;- this.getSolr().commit(true);+ this.solrInstances.getDefaultConnector().commit(true);}public void clearLocalSolr() throws IOException {- this.solr.clear0();+ EmbeddedInstance instance = this.solrInstances.getSolr0();+ if (instance != null) {+ for (String name: instance.getCoreNames()) new EmbeddedSolrConnector(instance, name).clear();+ }+ this.solrInstances.clearCache();}public void clearRemoteSolr() throws IOException {- this.solr.clear1();+ ShardInstance instance = this.solrInstances.getSolr1();+ if (instance != null) {+ for (String name: instance.getCoreNames()) new RemoteSolrConnector(instance, name).clear();+ }+ this.solrInstances.clearCache();}+ /**+ * get the size of the default index+ * @return+ */public int size() {int size = this.urlIndexFile == null ? 0 : this.urlIndexFile.size();- size += this.solr.getSize();+ size += this.solrInstances.getDefaultConnector().getSize();return size;}@@ -230,18 +267,19 @@ public final class Fulltext {this.urlIndexFile.close();this.urlIndexFile = null;}- this.solr.close();+ this.solrInstances.close();}public void commit(boolean softCommit) {- this.solr.commit(softCommit);+ getDefaultConnector().commit(softCommit);+ getWebgraphConnector().commit(softCommit);}public Date getLoadDate(final String urlHash) {if (urlHash == null) return null;Date x;try {- x = (Date) this.solr.getFieldById(urlHash, YaCySchema.load_date_dt.getSolrFieldName());+ x = (Date) this.solrInstances.getDefaultConnector().getFieldById(urlHash, CollectionSchema.load_date_dt.getSolrFieldName());} catch (IOException e) {return null;}@@ -252,7 +290,7 @@ public final class Fulltext {if (urlHash == null) return null;String x;try {- x = (String) this.solr.getFieldById(ASCII.String(urlHash), YaCySchema.sku.getSolrFieldName());+ x = (String) this.solrInstances.getDefaultConnector().getFieldById(ASCII.String(urlHash), CollectionSchema.sku.getSolrFieldName());} catch (IOException e) {return null;}@@ -279,7 +317,7 @@ public final class Fulltext {// get the metadata from Solrtry {- SolrDocument doc = this.solr.getById(ASCII.String(urlHash));+ SolrDocument doc = this.solrInstances.getDefaultConnector().getById(ASCII.String(urlHash));if (doc != null) {if (this.urlIndexFile != null) this.urlIndexFile.remove(urlHash);return new URIMetadataNode(doc, wre, weight);@@ -294,7 +332,7 @@ public final class Fulltext {final Row.Entry entry = this.urlIndexFile.remove(urlHash);if (entry == null) return null;URIMetadataRow row = new URIMetadataRow(entry, wre);- SolrInputDocument solrInput = this.solrSchema.metadata2solr(row);+ SolrInputDocument solrInput = this.collectionConfiguration.metadata2solr(row);this.putDocument(solrInput);return new URIMetadataNode(solrInput, wre, weight);} catch (final IOException e) {@@ -305,18 +343,18 @@ public final class Fulltext {}public void putDocument(final SolrInputDocument doc) throws IOException {- String id = (String) doc.getFieldValue(YaCySchema.id.getSolrFieldName());+ String id = (String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName());byte[] idb = ASCII.getBytes(id);try {if (this.urlIndexFile != null) this.urlIndexFile.remove(idb);- Date sdDate = (Date) this.solr.getFieldById(id, YaCySchema.last_modified.getSolrFieldName());+ Date sdDate = (Date) this.solrInstances.getDefaultConnector().getFieldById(id, CollectionSchema.last_modified.getSolrFieldName());Date docDate = null;- if (sdDate == null || (docDate = SolrConfiguration.getDate(doc, YaCySchema.last_modified)) == null || sdDate.before(docDate)) {- if (this.solrSchema.contains(YaCySchema.ip_s)) {+ if (sdDate == null || (docDate = SchemaConfiguration.getDate(doc, CollectionSchema.last_modified)) == null || sdDate.before(docDate)) {+ if (this.collectionConfiguration.contains(CollectionSchema.ip_s)) {// ip_s needs a dns lookup which causes blockings during search here- this.solr.add(doc);- } else synchronized (this.solr) {- this.solr.add(doc);+ this.solrInstances.getDefaultConnector().add(doc);+ } else synchronized (this.solrInstances) {+ this.solrInstances.getDefaultConnector().add(doc);}}} catch (SolrException e) {@@ -333,13 +371,13 @@ public final class Fulltext {String id = ASCII.String(idb);try {if (this.urlIndexFile != null) this.urlIndexFile.remove(idb);- SolrDocument sd = this.solr.getById(id);+ SolrDocument sd = this.solrInstances.getDefaultConnector().getById(id);if (sd == null || (new URIMetadataNode(sd)).isOlder(row)) {- if (this.solrSchema.contains(YaCySchema.ip_s)) {+ if (this.collectionConfiguration.contains(CollectionSchema.ip_s)) {// ip_s needs a dns lookup which causes blockings during search here- this.solr.add(getSolrSchema().metadata2solr(row));- } else synchronized (this.solr) {- this.solr.add(getSolrSchema().metadata2solr(row));+ this.solrInstances.getDefaultConnector().add(getDefaultConfiguration().metadata2solr(row));+ } else synchronized (this.solrInstances) {+ this.solrInstances.getDefaultConnector().add(getDefaultConfiguration().metadata2solr(row));}}} catch (SolrException e) {@@ -359,14 +397,14 @@ public final class Fulltext {public void deleteDomainHashpart(final String hosthash, Date freshdate, boolean concurrent) {// first collect all url hashes that belong to the domainassert hosthash.length() == 6;- final String q = YaCySchema.host_id_s.getSolrFieldName() + ":\"" + hosthash + "\"" +- ((freshdate != null && freshdate.before(new Date())) ? (" AND " + YaCySchema.load_date_dt.getSolrFieldName() + ":[* TO " + ISO8601Formatter.FORMATTER.format(freshdate) + "]") : "");+ final String q = CollectionSchema.host_id_s.getSolrFieldName() + ":\"" + hosthash + "\"" ++ ((freshdate != null && freshdate.before(new Date())) ? (" AND " + CollectionSchema.load_date_dt.getSolrFieldName() + ":[* TO " + ISO8601Formatter.FORMATTER.format(freshdate) + "]") : "");Thread t = new Thread() {public void run() {// delete in solr- synchronized (Fulltext.this.solr) {+ synchronized (Fulltext.this.solrInstances) {try {- Fulltext.this.solr.deleteByQuery(q);+ Fulltext.this.solrInstances.getDefaultConnector().deleteByQuery(q);} catch (IOException e) {}}@@ -405,20 +443,20 @@ public final class Fulltext {};if (concurrent) t.start(); else {t.run();- Fulltext.this.getSolr().commit(true);+ Fulltext.this.getDefaultConnector().commit(true);}}public void deleteDomainHostname(final String hostname, Date freshdate, boolean concurrent) {// first collect all url hashes that belong to the domain- final String q = YaCySchema.host_s.getSolrFieldName() + ":\"" + hostname + "\"" +- ((freshdate != null && freshdate.before(new Date())) ? (" AND " + YaCySchema.load_date_dt.getSolrFieldName() + ":[* TO " + ISO8601Formatter.FORMATTER.format(freshdate) + "]") : "");+ final String q = CollectionSchema.host_s.getSolrFieldName() + ":\"" + hostname + "\"" ++ ((freshdate != null && freshdate.before(new Date())) ? (" AND " + CollectionSchema.load_date_dt.getSolrFieldName() + ":[* TO " + ISO8601Formatter.FORMATTER.format(freshdate) + "]") : "");Thread t = new Thread() {public void run() {// delete in solr- synchronized (Fulltext.this.solr) {+ synchronized (Fulltext.this.solrInstances) {try {- Fulltext.this.solr.deleteByQuery(q);+ Fulltext.this.getDefaultConnector().deleteByQuery(q);} catch (IOException e) {}}// finally remove the line with statistics@@ -437,7 +475,7 @@ public final class Fulltext {};if (concurrent) t.start(); else {t.run();- Fulltext.this.getSolr().commit(true);+ Fulltext.this.getDefaultConnector().commit(true);}}@@ -451,22 +489,22 @@ public final class Fulltext {DigestURI uri;try {uri = new DigestURI(basepath);} catch (MalformedURLException e) {return 0;}final String host = uri.getHost();- final String q = YaCySchema.host_s.getSolrFieldName() + ":\"" + host + "\"" +- ((freshdate != null && freshdate.before(new Date())) ? (" AND " + YaCySchema.load_date_dt.getSolrFieldName() + ":[* TO " + ISO8601Formatter.FORMATTER.format(freshdate) + "]") : "");+ final String q = CollectionSchema.host_s.getSolrFieldName() + ":\"" + host + "\"" ++ ((freshdate != null && freshdate.before(new Date())) ? (" AND " + CollectionSchema.load_date_dt.getSolrFieldName() + ":[* TO " + ISO8601Formatter.FORMATTER.format(freshdate) + "]") : "");final AtomicInteger count = new AtomicInteger(0);Thread t = new Thread(){public void run() {- final BlockingQueue<SolrDocument> docs = getSolr().concurrentQuery(q, 0, 1000000, 600000, -1, YaCySchema.id.getSolrFieldName(), YaCySchema.sku.getSolrFieldName());+ final BlockingQueue<SolrDocument> docs = Fulltext.this.getDefaultConnector().concurrentQuery(q, 0, 1000000, 600000, -1, CollectionSchema.id.getSolrFieldName(), CollectionSchema.sku.getSolrFieldName());try {SolrDocument doc;while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {- String u = (String) doc.getFieldValue(YaCySchema.sku.getSolrFieldName());+ String u = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());if (u.startsWith(basepath)) {- remove(ASCII.getBytes((String) doc.getFieldValue(YaCySchema.id.getSolrFieldName())));+ remove(ASCII.getBytes((String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName())));count.incrementAndGet();}}- if (count.get() > 0) Fulltext.this.solr.commit(true);+ if (count.get() > 0) Fulltext.this.getDefaultConnector().commit(true);} catch (InterruptedException e) {}}};@@ -484,11 +522,11 @@ public final class Fulltext {Thread t = new Thread() {public void run() {try {- synchronized (Fulltext.this.solr) {+ synchronized (Fulltext.this.solrInstances) {for (byte[] urlHash: deleteIDs) {- Fulltext.this.solr.delete(ASCII.String(urlHash));+ Fulltext.this.getDefaultConnector().delete(ASCII.String(urlHash));}- Fulltext.this.solr.commit(true);+ Fulltext.this.getDefaultConnector().commit(true);}} catch (final Throwable e) {Log.logException(e);@@ -506,8 +544,8 @@ public final class Fulltext {public boolean remove(final byte[] urlHash) {if (urlHash == null) return false;try {- synchronized (this.solr) {- this.solr.delete(ASCII.String(urlHash));+ synchronized (this.solrInstances) {+ this.getDefaultConnector().delete(ASCII.String(urlHash));}} catch (final Throwable e) {Log.logException(e);@@ -526,7 +564,7 @@ public final class Fulltext {if (urlHash == null) return false;if (this.urlIndexFile != null && this.urlIndexFile.has(urlHash)) return true;try {- if (this.solr.exists(YaCySchema.id.getSolrFieldName(), ASCII.String(urlHash))) return true;+ if (this.getDefaultConnector().exists(CollectionSchema.id.getSolrFieldName(), ASCII.String(urlHash))) return true;} catch (final Throwable e) {Log.logException(e);}@@ -535,24 +573,23 @@ public final class Fulltext {public String failReason(final String urlHash) throws IOException {if (urlHash == null) return null;- String reason = (String) this.solr.getFieldById(urlHash, YaCySchema.failreason_t.getSolrFieldName());+ String reason = (String) this.getDefaultConnector().getFieldById(urlHash, CollectionSchema.failreason_t.getSolrFieldName());if (reason == null) return null;return reason == null ? null : reason.length() == 0 ? null : reason;}public List<File> dumpFiles() {- EmbeddedSolrConnector esc = (EmbeddedSolrConnector) this.solr.getSolr0();+ EmbeddedInstance esc = this.solrInstances.getSolr0();ArrayList<File> zips = new ArrayList<File>();if (esc == null) {Log.logWarning("Fulltext", "HOT DUMP selected solr0 == NULL, no dump list!");return zips;}- SolrEmbeddedInstance sei = (SolrEmbeddedInstance) esc.getInstance();- if (sei.getStoragePath() == null) {+ if (esc.getContainerPath() == null) {Log.logWarning("Fulltext", "HOT DUMP selected solr0.getStoragePath() == NULL, no dump list!");return zips;}- File storagePath = sei.getStoragePath().getParentFile();+ File storagePath = esc.getContainerPath().getParentFile();if (storagePath == null) {Log.logWarning("Fulltext", "HOT DUMP selected esc.getStoragePath().getParentFile() == NULL, no dump list!");return zips;@@ -569,17 +606,18 @@ public final class Fulltext {* @return*/public File dumpSolr() {- EmbeddedSolrConnector esc = (EmbeddedSolrConnector) this.solr.getSolr0();- SolrEmbeddedInstance sei = (SolrEmbeddedInstance) esc.getInstance();- File storagePath = sei.getStoragePath();+ EmbeddedInstance esc = this.solrInstances.getSolr0();+ File storagePath = esc.getContainerPath();File zipOut = new File(storagePath.toString() + "_" + GenericFormatter.SHORT_DAY_FORMATTER.format() + ".zip");- synchronized (this.solr) {+ synchronized (this.solrInstances) {this.disconnectLocalSolr();+ this.solrInstances.close();try {ZIPWriter.zip(storagePath, zipOut);} catch (IOException e) {Log.logException(e);} finally {+ this.solrInstances = new InstanceMirror();try {this.connectLocalSolr();} catch (IOException e) {@@ -595,16 +633,17 @@ public final class Fulltext {* @param solrDumpZipFile*/public void restoreSolr(File solrDumpZipFile) {- EmbeddedSolrConnector esc = (EmbeddedSolrConnector) this.solr.getSolr0();- SolrEmbeddedInstance sei = (SolrEmbeddedInstance) esc.getInstance();- File storagePath = sei.getStoragePath();- synchronized (this.solr) {+ EmbeddedInstance esc = this.solrInstances.getSolr0();+ File storagePath = esc.getContainerPath();+ synchronized (this.solrInstances) {this.disconnectLocalSolr();+ this.solrInstances.close();try {ZIPReader.unzip(solrDumpZipFile, storagePath);} catch (IOException e) {Log.logException(e);} finally {+ this.solrInstances = new InstanceMirror();try {this.connectLocalSolr();} catch (IOException e) {@@ -669,8 +708,8 @@ public final class Fulltext {if (this.dom) {- Map<String, ReversibleScoreMap<String>> scores = Fulltext.this.getSolr().getFacets(YaCySchema.httpstatus_i.getSolrFieldName() + ":200", 100000, YaCySchema.host_s.getSolrFieldName());- ReversibleScoreMap<String> stats = scores.get(YaCySchema.host_s.getSolrFieldName());+ Map<String, ReversibleScoreMap<String>> scores = Fulltext.this.getDefaultConnector().getFacets(CollectionSchema.httpstatus_i.getSolrFieldName() + ":200", 100000, CollectionSchema.host_s.getSolrFieldName());+ ReversibleScoreMap<String> stats = scores.get(CollectionSchema.host_s.getSolrFieldName());for (final String host: stats) {if (this.pattern != null && !this.pattern.matcher(host).matches()) continue;if (this.format == 0) pw.println(host);@@ -678,22 +717,22 @@ public final class Fulltext {this.count++;}} else {- BlockingQueue<SolrDocument> docs = Fulltext.this.getSolr().concurrentQuery(YaCySchema.httpstatus_i.getSolrFieldName() + ":200", 0, 100000000, 10 * 60 * 60 * 1000, 100,- YaCySchema.id.getSolrFieldName(), YaCySchema.sku.getSolrFieldName(), YaCySchema.title.getSolrFieldName(),- YaCySchema.author.getSolrFieldName(), YaCySchema.description.getSolrFieldName(), YaCySchema.size_i.getSolrFieldName(), YaCySchema.last_modified.getSolrFieldName());+ BlockingQueue<SolrDocument> docs = Fulltext.this.getDefaultConnector().concurrentQuery(CollectionSchema.httpstatus_i.getSolrFieldName() + ":200", 0, 100000000, 10 * 60 * 60 * 1000, 100,+ CollectionSchema.id.getSolrFieldName(), CollectionSchema.sku.getSolrFieldName(), CollectionSchema.title.getSolrFieldName(),+ CollectionSchema.author.getSolrFieldName(), CollectionSchema.description.getSolrFieldName(), CollectionSchema.size_i.getSolrFieldName(), CollectionSchema.last_modified.getSolrFieldName());SolrDocument doc;ArrayList<?> title;String url, author, description, hash;Integer size;Date date;while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {- hash = (String) doc.getFieldValue(YaCySchema.id.getSolrFieldName());- url = (String) doc.getFieldValue(YaCySchema.sku.getSolrFieldName());- title = (ArrayList<?>) doc.getFieldValue(YaCySchema.title.getSolrFieldName());- author = (String) doc.getFieldValue(YaCySchema.author.getSolrFieldName());- description = (String) doc.getFieldValue(YaCySchema.description.getSolrFieldName());- size = (Integer) doc.getFieldValue(YaCySchema.size_i.getSolrFieldName());- date = (Date) doc.getFieldValue(YaCySchema.last_modified.getSolrFieldName());+ hash = (String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName());+ url = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());+ title = (ArrayList<?>) doc.getFieldValue(CollectionSchema.title.getSolrFieldName());+ author = (String) doc.getFieldValue(CollectionSchema.author.getSolrFieldName());+ description = (String) doc.getFieldValue(CollectionSchema.description.getSolrFieldName());+ size = (Integer) doc.getFieldValue(CollectionSchema.size_i.getSolrFieldName());+ date = (Date) doc.getFieldValue(CollectionSchema.last_modified.getSolrFieldName());if (this.pattern != null && !this.pattern.matcher(url).matches()) continue;if (this.format == 0) {pw.println(url);diff --git a/source/net/yacy/search/index/Segment.java b/source/net/yacy/search/index/Segment.javaindex 405357273..94da14db4 100644--- a/source/net/yacy/search/index/Segment.java+++ b/source/net/yacy/search/index/Segment.java@@ -44,7 +44,6 @@ import org.apache.solr.common.SolrInputDocument;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.solr.connector.AbstractSolrConnector;import net.yacy.cora.federate.yacy.CacheStrategy;import net.yacy.cora.order.Base64Order;@@ -78,6 +77,9 @@ import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;import net.yacy.search.query.RankingProcess;import net.yacy.search.query.SearchEvent;+import net.yacy.search.schema.CollectionConfiguration;+import net.yacy.search.schema.CollectionSchema;+import net.yacy.search.schema.WebgraphConfiguration;public class Segment {@@ -112,13 +114,20 @@ public class Segment {protected IndexCell<WordReference> termIndex;protected IndexCell<CitationReference> urlCitationIndex;- public Segment(final Log log, final File segmentPath, final SolrConfiguration solrSchema) {+ /**+ * create a new Segment+ * @param log+ * @param segmentPath that should be the path ponting to the directory "SEGMENT"+ * @param collectionSchema+ */+ public Segment(final Log log, final File segmentPath,+ final CollectionConfiguration collectionConfiguration, final WebgraphConfiguration webgraphConfiguration) {log.logInfo("Initializing Segment '" + segmentPath + ".");this.log = log;this.segmentPath = segmentPath;// create LURL-db- this.fulltext = new Fulltext(segmentPath, solrSchema);+ this.fulltext = new Fulltext(segmentPath, collectionConfiguration, webgraphConfiguration);}public boolean connectedRWI() {@@ -128,7 +137,7 @@ public class Segment {public void connectRWI(final int entityCacheMaxSize, final long maxFileSize) throws IOException {if (this.termIndex != null) return;this.termIndex = new IndexCell<WordReference>(- this.segmentPath,+ new File(this.segmentPath, "default"),termIndexName,wordReferenceFactory,wordOrder,@@ -152,7 +161,7 @@ public class Segment {public void connectCitation(final int entityCacheMaxSize, final long maxFileSize) throws IOException {if (this.urlCitationIndex != null) return;this.urlCitationIndex = new IndexCell<CitationReference>(- this.segmentPath,+ new File(this.segmentPath, "default"),citationIndexName,citationReferenceFactory,wordOrder,@@ -206,7 +215,7 @@ public class Segment {public int getQueryCount(String word) {if (word == null || word.indexOf(':') >= 0 || word.indexOf(' ') >= 0 || word.indexOf('/') >= 0) return 0;int count = this.termIndex == null ? 0 : this.termIndex.count(Word.word2hash(word));- try {count += this.fulltext.getSolr().getQueryCount(YaCySchema.text_t.getSolrFieldName() + ':' + word);} catch (IOException e) {}+ try {count += this.fulltext.getDefaultConnector().getQueryCount(CollectionSchema.text_t.getSolrFieldName() + ':' + word);} catch (IOException e) {}return count;}@@ -223,12 +232,12 @@ public class Segment {final BlockingQueue<SolrDocument> docQueue;final String urlstub;if (stub == null) {- docQueue = this.fulltext.getSolr().concurrentQuery("*:*", 0, Integer.MAX_VALUE, maxtime, maxcount, YaCySchema.id.getSolrFieldName(), YaCySchema.sku.getSolrFieldName());+ docQueue = this.fulltext.getDefaultConnector().concurrentQuery("*:*", 0, Integer.MAX_VALUE, maxtime, maxcount, CollectionSchema.id.getSolrFieldName(), CollectionSchema.sku.getSolrFieldName());urlstub = null;} else {final String host = stub.getHost();String hh = DigestURI.hosthash(host);- docQueue = this.fulltext.getSolr().concurrentQuery(YaCySchema.host_id_s + ":\"" + hh + "\"", 0, Integer.MAX_VALUE, maxtime, maxcount, YaCySchema.id.getSolrFieldName(), YaCySchema.sku.getSolrFieldName());+ docQueue = this.fulltext.getDefaultConnector().concurrentQuery(CollectionSchema.host_id_s + ":\"" + hh + "\"", 0, Integer.MAX_VALUE, maxtime, maxcount, CollectionSchema.id.getSolrFieldName(), CollectionSchema.sku.getSolrFieldName());urlstub = stub.toNormalform(true);}@@ -245,8 +254,8 @@ public class Segment {return null;}if (doc == null || doc == AbstractSolrConnector.POISON_DOCUMENT) return null;- String u = (String) doc.getFieldValue(YaCySchema.sku.getSolrFieldName());- String id = (String) doc.getFieldValue(YaCySchema.id.getSolrFieldName());+ String u = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());+ String id = (String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName());DigestURI url;try {url = new DigestURI(u, ASCII.getBytes(id));@@ -368,15 +377,15 @@ public class Segment {// DO A SOFT/HARD COMMIT IF NEEDEDif (MemoryControl.shortStatus()) {// do a 'hard' commit to flush index caches- this.fulltext.getSolr().commit(false);+ this.fulltext.getDefaultConnector().commit(false);} else {if (- (this.fulltext.getSolrSchema().contains(YaCySchema.exact_signature_l) && this.fulltext.getSolrSchema().contains(YaCySchema.exact_signature_unique_b)) ||- (this.fulltext.getSolrSchema().contains(YaCySchema.fuzzy_signature_l) && this.fulltext.getSolrSchema().contains(YaCySchema.fuzzy_signature_unique_b)) ||- this.fulltext.getSolrSchema().contains(YaCySchema.title_unique_b) ||- this.fulltext.getSolrSchema().contains(YaCySchema.description_unique_b)+ (this.fulltext.getDefaultConfiguration().contains(CollectionSchema.exact_signature_l) && this.fulltext.getDefaultConfiguration().contains(CollectionSchema.exact_signature_unique_b)) ||+ (this.fulltext.getDefaultConfiguration().contains(CollectionSchema.fuzzy_signature_l) && this.fulltext.getDefaultConfiguration().contains(CollectionSchema.fuzzy_signature_unique_b)) ||+ this.fulltext.getDefaultConfiguration().contains(CollectionSchema.title_unique_b) ||+ this.fulltext.getDefaultConfiguration().contains(CollectionSchema.description_unique_b)) {- this.fulltext.getSolr().commit(true); // make sure that we have latest information for the postprocessing steps+ this.fulltext.getDefaultConnector().commit(true); // make sure that we have latest information for the postprocessing steps}}@@ -395,19 +404,19 @@ public class Segment {char docType = Response.docType(document.dc_format());// CREATE SOLR DOCUMENT- final SolrInputDocument solrInputDoc = this.fulltext.getSolrSchema().yacy2solr(id, profile, responseHeader, document, condenser, referrerURL, language, urlCitationIndex);+ final SolrInputDocument solrInputDoc = this.fulltext.getDefaultConfiguration().yacy2solr(id, profile, responseHeader, document, condenser, referrerURL, language, urlCitationIndex);// FIND OUT IF THIS IS A DOUBLE DOCUMENT- for (YaCySchema[] checkfields: new YaCySchema[][]{- {YaCySchema.exact_signature_l, YaCySchema.exact_signature_unique_b},- {YaCySchema.fuzzy_signature_l, YaCySchema.fuzzy_signature_unique_b}}) {- YaCySchema checkfield = checkfields[0];- YaCySchema uniquefield = checkfields[1];- if (this.fulltext.getSolrSchema().contains(checkfield) && this.fulltext.getSolrSchema().contains(uniquefield)) {+ for (CollectionSchema[] checkfields: new CollectionSchema[][]{+ {CollectionSchema.exact_signature_l, CollectionSchema.exact_signature_unique_b},+ {CollectionSchema.fuzzy_signature_l, CollectionSchema.fuzzy_signature_unique_b}}) {+ CollectionSchema checkfield = checkfields[0];+ CollectionSchema uniquefield = checkfields[1];+ if (this.fulltext.getDefaultConfiguration().contains(checkfield) && this.fulltext.getDefaultConfiguration().contains(uniquefield)) {// lookup the document with the same signaturelong signature = ((Long) solrInputDoc.getField(checkfield.getSolrFieldName()).getValue()).longValue();try {- if (this.fulltext.getSolr().exists(checkfield.getSolrFieldName(), Long.toString(signature))) {+ if (this.fulltext.getDefaultConnector().exists(checkfield.getSolrFieldName(), Long.toString(signature))) {// change unique attribut in contentsolrInputDoc.setField(uniquefield.getSolrFieldName(), false);}@@ -416,29 +425,29 @@ public class Segment {}// CHECK IF TITLE AND DESCRIPTION IS UNIQUE (this is by default not switched on)- uniquecheck: for (YaCySchema[] checkfields: new YaCySchema[][]{- {YaCySchema.title, YaCySchema.title_unique_b},- {YaCySchema.description, YaCySchema.description_unique_b}}) {- YaCySchema checkfield = checkfields[0];- YaCySchema uniquefield = checkfields[1];- if (this.fulltext.getSolrSchema().contains(checkfield) && this.fulltext.getSolrSchema().contains(uniquefield)) {+ uniquecheck: for (CollectionSchema[] checkfields: new CollectionSchema[][]{+ {CollectionSchema.title, CollectionSchema.title_unique_b},+ {CollectionSchema.description, CollectionSchema.description_unique_b}}) {+ CollectionSchema checkfield = checkfields[0];+ CollectionSchema uniquefield = checkfields[1];+ if (this.fulltext.getDefaultConfiguration().contains(checkfield) && this.fulltext.getDefaultConfiguration().contains(uniquefield)) {// lookup in the index for the same title- String checkstring = checkfield == YaCySchema.title ? document.dc_title() : document.dc_description();+ String checkstring = checkfield == CollectionSchema.title ? document.dc_title() : document.dc_description();if (checkstring.length() == 0) {solrInputDoc.setField(uniquefield.getSolrFieldName(), false);continue uniquecheck;}checkstring = ClientUtils.escapeQueryChars("\"" + checkstring + "\"");try {- if (this.fulltext.getSolr().exists(checkfield.getSolrFieldName(), checkstring)) {+ if (this.fulltext.getDefaultConnector().exists(checkfield.getSolrFieldName(), checkstring)) {// switch unique attribute in new documentsolrInputDoc.setField(uniquefield.getSolrFieldName(), false);// switch attribute also in all existing documents (which should be exactly only one!)- SolrDocumentList docs = this.fulltext.getSolr().query(checkfield.getSolrFieldName() + ":" + checkstring + " AND " + uniquefield.getSolrFieldName() + ":true", 0, 1000);+ SolrDocumentList docs = this.fulltext.getDefaultConnector().query(checkfield.getSolrFieldName() + ":" + checkstring + " AND " + uniquefield.getSolrFieldName() + ":true", 0, 1000);for (SolrDocument doc: docs) {- SolrInputDocument sid = this.fulltext.getSolrSchema().toSolrInputDocument(doc);+ SolrInputDocument sid = this.fulltext.getDefaultConfiguration().toSolrInputDocument(doc);sid.setField(uniquefield.getSolrFieldName(), false);- this.fulltext.getSolr().add(sid);+ this.fulltext.getDefaultConnector().add(sid);}} else {solrInputDoc.setField(uniquefield.getSolrFieldName(), true);@@ -448,9 +457,9 @@ public class Segment {}// ENRICH DOCUMENT WITH RANKING INFORMATION- if (this.urlCitationIndex != null && this.fulltext.getSolrSchema().contains(YaCySchema.references_i)) {+ if (this.urlCitationIndex != null && this.fulltext.getDefaultConfiguration().contains(CollectionSchema.references_i)) {int references = this.urlCitationIndex.count(url.hash());- if (references > 0) solrInputDoc.setField(YaCySchema.references_i.getSolrFieldName(), references);+ if (references > 0) solrInputDoc.setField(CollectionSchema.references_i.getSolrFieldName(), references);}// STORE TO SOLRdiff --git a/source/net/yacy/search/query/QueryGoal.java b/source/net/yacy/search/query/QueryGoal.javaindex 53a6d520a..66afd280e 100644--- a/source/net/yacy/search/query/QueryGoal.java+++ b/source/net/yacy/search/query/QueryGoal.java@@ -28,13 +28,13 @@ import java.util.Map;import java.util.SortedSet;import net.yacy.cora.federate.solr.Boost;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.storage.HandleSet;import net.yacy.document.parser.html.AbstractScraper;import net.yacy.document.parser.html.CharacterCoding;import net.yacy.kelondro.data.word.Word;import net.yacy.search.index.Segment;-import net.yacy.search.index.SolrConfiguration;+import net.yacy.search.schema.CollectionConfiguration;+import net.yacy.search.schema.CollectionSchema;public class QueryGoal {@@ -203,7 +203,7 @@ public class QueryGoal {for (final byte[] b: blues) this.include_hashes.remove(b);}- public StringBuilder solrQueryString(SolrConfiguration configuration) {+ public StringBuilder solrQueryString(CollectionConfiguration configuration) {final StringBuilder q = new StringBuilder(80);// parse special requests@@ -230,8 +230,8 @@ public class QueryGoal {// combine these queries for all relevant fieldswc = 0;Float boost;- for (Map.Entry<YaCySchema,Float> entry: Boost.RANKING.entrySet()) {- YaCySchema field = entry.getKey();+ for (Map.Entry<CollectionSchema,Float> entry: Boost.RANKING.entrySet()) {+ CollectionSchema field = entry.getKey();if (entry.getValue().floatValue() < 0.0f) continue;if (configuration != null && !configuration.contains(field.getSolrFieldName())) continue;if (wc > 0) q.append(" OR ");@@ -246,7 +246,7 @@ public class QueryGoal {q.append(')');// add filter to prevent that results come from failed urls- q.append(" AND ").append(YaCySchema.httpstatus_i.getSolrFieldName()).append(":200");+ q.append(" AND ").append(CollectionSchema.httpstatus_i.getSolrFieldName()).append(":200");//q.append(" AND -").append(YaCySchema.failreason_t.getSolrFieldName()).append(":[* TO *]");return q;diff --git a/source/net/yacy/search/query/QueryModifier.java b/source/net/yacy/search/query/QueryModifier.javaindex 97316f704..b93ec8d95 100644--- a/source/net/yacy/search/query/QueryModifier.java+++ b/source/net/yacy/search/query/QueryModifier.java@@ -22,8 +22,8 @@ package net.yacy.search.query;import org.apache.solr.common.params.CommonParams;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.kelondro.data.meta.DigestURI;+import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;@@ -149,30 +149,30 @@ public class QueryModifier {final StringBuilder fq = new StringBuilder(post.get(CommonParams.FQ,""));- if (this.sitehost != null && this.sitehost.length() > 0 && fq.indexOf(YaCySchema.host_s.getSolrFieldName()) < 0) {+ if (this.sitehost != null && this.sitehost.length() > 0 && fq.indexOf(CollectionSchema.host_s.getSolrFieldName()) < 0) {// consider to search for hosts with 'www'-prefix, if not already part of the host nameif (this.sitehost.startsWith("www.")) {- fq.append(" AND (").append(YaCySchema.host_s.getSolrFieldName()).append(":\"").append(this.sitehost.substring(4)).append('\"');- fq.append(" OR ").append(YaCySchema.host_s.getSolrFieldName()).append(":\"").append(this.sitehost).append("\")");+ fq.append(" AND (").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"").append(this.sitehost.substring(4)).append('\"');+ fq.append(" OR ").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"").append(this.sitehost).append("\")");} else {- fq.append(" AND (").append(YaCySchema.host_s.getSolrFieldName()).append(":\"").append(this.sitehost).append('\"');- fq.append(" OR ").append(YaCySchema.host_s.getSolrFieldName()).append(":\"www.").append(this.sitehost).append("\")");+ fq.append(" AND (").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"").append(this.sitehost).append('\"');+ fq.append(" OR ").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"www.").append(this.sitehost).append("\")");}}- if (this.sitehash != null && this.sitehash.length() > 0 && fq.indexOf(YaCySchema.host_id_s.getSolrFieldName()) < 0) {- fq.append(" AND ").append(YaCySchema.host_id_s.getSolrFieldName()).append(":\"").append(this.sitehash).append('\"');+ if (this.sitehash != null && this.sitehash.length() > 0 && fq.indexOf(CollectionSchema.host_id_s.getSolrFieldName()) < 0) {+ fq.append(" AND ").append(CollectionSchema.host_id_s.getSolrFieldName()).append(":\"").append(this.sitehash).append('\"');}- if (this.filetype != null && this.filetype.length() > 0 && fq.indexOf(YaCySchema.url_file_ext_s.getSolrFieldName()) < 0) {- fq.append(" AND ").append(YaCySchema.url_file_ext_s.getSolrFieldName()).append(":\"").append(this.filetype).append('\"');+ if (this.filetype != null && this.filetype.length() > 0 && fq.indexOf(CollectionSchema.url_file_ext_s.getSolrFieldName()) < 0) {+ fq.append(" AND ").append(CollectionSchema.url_file_ext_s.getSolrFieldName()).append(":\"").append(this.filetype).append('\"');}- if (this.author != null && this.author.length() > 0 && fq.indexOf(YaCySchema.author_sxt.getSolrFieldName()) < 0) {- fq.append(" AND ").append(YaCySchema.author_sxt.getSolrFieldName()).append(":\"").append(this.author).append('\"');+ if (this.author != null && this.author.length() > 0 && fq.indexOf(CollectionSchema.author_sxt.getSolrFieldName()) < 0) {+ fq.append(" AND ").append(CollectionSchema.author_sxt.getSolrFieldName()).append(":\"").append(this.author).append('\"');}- if (this.protocol != null && this.protocol.length() > 0 && fq.indexOf(YaCySchema.url_protocol_s.getSolrFieldName()) < 0) {- fq.append(" AND ").append(YaCySchema.url_protocol_s.getSolrFieldName()).append(":\"").append(this.protocol).append('\"');+ if (this.protocol != null && this.protocol.length() > 0 && fq.indexOf(CollectionSchema.url_protocol_s.getSolrFieldName()) < 0) {+ fq.append(" AND ").append(CollectionSchema.url_protocol_s.getSolrFieldName()).append(":\"").append(this.protocol).append('\"');}if (fq.length() > 0) {diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.javaindex fdf71c638..339edd344 100644--- a/source/net/yacy/search/query/QueryParams.java+++ b/source/net/yacy/search/query/QueryParams.java@@ -48,7 +48,6 @@ import net.yacy.cora.document.analysis.Classification;import net.yacy.cora.document.analysis.Classification.ContentDomain;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.federate.solr.Boost;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.yacy.CacheStrategy;import net.yacy.cora.geo.GeoLocation;import net.yacy.cora.lod.vocabulary.Tagging;@@ -67,8 +66,9 @@ import net.yacy.kelondro.util.Bitfield;import net.yacy.kelondro.util.SetTools;import net.yacy.peers.Seed;import net.yacy.search.index.Segment;-import net.yacy.search.index.SolrConfiguration;import net.yacy.search.ranking.RankingProfile;+import net.yacy.search.schema.CollectionConfiguration;+import net.yacy.search.schema.CollectionSchema;public final class QueryParams {@@ -84,8 +84,8 @@ public final class QueryParams {}}- private static final YaCySchema[] defaultfacetfields = new YaCySchema[]{- YaCySchema.host_s, YaCySchema.url_protocol_s, YaCySchema.url_file_ext_s, YaCySchema.author_sxt};+ private static final CollectionSchema[] defaultfacetfields = new CollectionSchema[]{+ CollectionSchema.host_s, CollectionSchema.url_protocol_s, CollectionSchema.url_file_ext_s, CollectionSchema.author_sxt};private static final int defaultmaxfacets = 30;private static final String ampersand = "&";@@ -128,7 +128,7 @@ public final class QueryParams {public List<String> facetfields;public int maxfacets;private SolrQuery cachedQuery;- private SolrConfiguration solrSchema;+ private CollectionConfiguration solrSchema;// the following values are filled during the search process as statistics for the searchpublic final AtomicInteger local_rwi_available; // the number of hits generated/ranked by the local search in rwi index@@ -191,11 +191,11 @@ public final class QueryParams {this.misses = Collections.synchronizedSortedSet(new TreeSet<byte[]>(URIMetadataRow.rowdef.objectOrder));this.facetfields = new ArrayList<String>();- this.solrSchema = indexSegment.fulltext().getSolrSchema();- for (YaCySchema f: defaultfacetfields) {+ this.solrSchema = indexSegment.fulltext().getDefaultConfiguration();+ for (CollectionSchema f: defaultfacetfields) {if (solrSchema.contains(f)) facetfields.add(f.getSolrFieldName());}- for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX);+ for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(CollectionSchema.VOCABULARY_PREFIX + v.getName() + CollectionSchema.VOCABULARY_SUFFIX);this.maxfacets = defaultmaxfacets;this.cachedQuery = null;}@@ -300,11 +300,11 @@ public final class QueryParams {this.misses = Collections.synchronizedSortedSet(new TreeSet<byte[]>(URIMetadataRow.rowdef.objectOrder));this.facetfields = new ArrayList<String>();- this.solrSchema = indexSegment.fulltext().getSolrSchema();- for (YaCySchema f: defaultfacetfields) {+ this.solrSchema = indexSegment.fulltext().getDefaultConfiguration();+ for (CollectionSchema f: defaultfacetfields) {if (solrSchema.contains(f)) facetfields.add(f.getSolrFieldName());}- for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX);+ for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(CollectionSchema.VOCABULARY_PREFIX + v.getName() + CollectionSchema.VOCABULARY_SUFFIX);this.maxfacets = defaultmaxfacets;this.cachedQuery = null;}@@ -432,7 +432,7 @@ public final class QueryParams {if (this.queryGoal.getIncludeStrings().size() == 0) return null;// construct queryfinal SolrQuery params = new SolrQuery();- params.setQuery(this.queryGoal.solrQueryString(this.indexSegment.fulltext().getSolrSchema()).toString());+ params.setQuery(this.queryGoal.solrQueryString(this.indexSegment.fulltext().getDefaultConfiguration()).toString());params.setParam("defType", "edismax");params.setParam("bq", Boost.RANKING.getBoostQuery()); // a boost query that moves double content to the backparams.setParam("bf", Boost.RANKING.getBoostFunction()); // a boost function extension@@ -445,47 +445,47 @@ public final class QueryParams {if (this.modifier.sitehash == null && this.modifier.sitehost == null) {if (this.siteexcludes != null) {for (String ex: this.siteexcludes) {- fq.append(" AND -").append(YaCySchema.host_id_s.getSolrFieldName()).append(':').append(ex);+ fq.append(" AND -").append(CollectionSchema.host_id_s.getSolrFieldName()).append(':').append(ex);}}} else {if (this.modifier.sitehost != null) {// consider to search for hosts with 'www'-prefix, if not already part of the host nameif (this.modifier.sitehost.startsWith("www.")) {- fq.append(" AND (").append(YaCySchema.host_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehost.substring(4)).append('\"');- fq.append(" OR ").append(YaCySchema.host_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehost).append("\")");+ fq.append(" AND (").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehost.substring(4)).append('\"');+ fq.append(" OR ").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehost).append("\")");} else {- fq.append(" AND (").append(YaCySchema.host_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehost).append('\"');- fq.append(" OR ").append(YaCySchema.host_s.getSolrFieldName()).append(":\"www.").append(this.modifier.sitehost).append("\")");+ fq.append(" AND (").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehost).append('\"');+ fq.append(" OR ").append(CollectionSchema.host_s.getSolrFieldName()).append(":\"www.").append(this.modifier.sitehost).append("\")");}} else- fq.append(" AND ").append(YaCySchema.host_id_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehash).append('\"');+ fq.append(" AND ").append(CollectionSchema.host_id_s.getSolrFieldName()).append(":\"").append(this.modifier.sitehash).append('\"');}// add vocabulary facetsfor (Tagging.Metatag tag: this.metatags) {- fq.append(" AND ").append(YaCySchema.VOCABULARY_PREFIX).append(tag.getVocabularyName()).append(YaCySchema.VOCABULARY_SUFFIX).append(":\"").append(tag.getObject()).append('\"');+ fq.append(" AND ").append(CollectionSchema.VOCABULARY_PREFIX).append(tag.getVocabularyName()).append(CollectionSchema.VOCABULARY_SUFFIX).append(":\"").append(tag.getObject()).append('\"');}// add author facets- if (this.modifier.author != null && this.modifier.author.length() > 0 && this.solrSchema.contains(YaCySchema.author_sxt)) {- fq.append(" AND ").append(YaCySchema.author_sxt.getSolrFieldName()).append(":\"").append(this.modifier.author).append('\"');+ if (this.modifier.author != null && this.modifier.author.length() > 0 && this.solrSchema.contains(CollectionSchema.author_sxt)) {+ fq.append(" AND ").append(CollectionSchema.author_sxt.getSolrFieldName()).append(":\"").append(this.modifier.author).append('\"');}if (this.modifier.protocol != null) {- fq.append(" AND ").append(YaCySchema.url_protocol_s.getSolrFieldName()).append(':').append(this.modifier.protocol);+ fq.append(" AND ").append(CollectionSchema.url_protocol_s.getSolrFieldName()).append(':').append(this.modifier.protocol);}if (this.tld != null) {- fq.append(" AND ").append(YaCySchema.host_dnc_s.getSolrFieldName()).append(":\"").append(this.tld).append('\"');+ fq.append(" AND ").append(CollectionSchema.host_dnc_s.getSolrFieldName()).append(":\"").append(this.tld).append('\"');}if (this.modifier.filetype != null) {- fq.append(" AND ").append(YaCySchema.url_file_ext_s.getSolrFieldName()).append(":\"").append(this.modifier.filetype).append('\"');+ fq.append(" AND ").append(CollectionSchema.url_file_ext_s.getSolrFieldName()).append(":\"").append(this.modifier.filetype).append('\"');}if (this.inlink != null) {- fq.append(" AND ").append(YaCySchema.outboundlinks_urlstub_txt.getSolrFieldName()).append(":\"").append(this.inlink).append('\"');+ fq.append(" AND ").append(CollectionSchema.outboundlinks_urlstub_txt.getSolrFieldName()).append(":\"").append(this.inlink).append('\"');}if (!this.urlMask_isCatchall) {@@ -497,7 +497,7 @@ public final class QueryParams {while ((p = urlMaskPattern.indexOf(':')) >= 0) urlMaskPattern = urlMaskPattern.substring(0, p) + "." + urlMaskPattern.substring(p + 1);while ((p = urlMaskPattern.indexOf('/')) >= 0) urlMaskPattern = urlMaskPattern.substring(0, p) + "." + urlMaskPattern.substring(p + 1);while ((p = urlMaskPattern.indexOf('\\')) >= 0) urlMaskPattern = urlMaskPattern.substring(0, p) + "." + urlMaskPattern.substring(p + 2);- fq.append(" AND ").append(YaCySchema.sku.getSolrFieldName() + ":/" + urlMaskPattern + "/");+ fq.append(" AND ").append(CollectionSchema.sku.getSolrFieldName() + ":/" + urlMaskPattern + "/");}if (this.radius > 0.0d && this.lat != 0.0d && this.lon != 0.0d) {@@ -508,13 +508,13 @@ public final class QueryParams {//params.set("sfield", YaCySchema.coordinate_p.name());//params.set("pt", Double.toString(this.lat) + "," + Double.toString(this.lon));//params.set("d", GeoLocation.degreeToKm(this.radius));- fq.append(" AND ").append("{!bbox sfield=" + YaCySchema.coordinate_p.getSolrFieldName() + " pt=" + Double.toString(this.lat) + "," + Double.toString(this.lon) + " d=" + GeoLocation.degreeToKm(this.radius) + "}");+ fq.append(" AND ").append("{!bbox sfield=" + CollectionSchema.coordinate_p.getSolrFieldName() + " pt=" + Double.toString(this.lat) + "," + Double.toString(this.lon) + " d=" + GeoLocation.degreeToKm(this.radius) + "}");//params.setRows(Integer.MAX_VALUE);} else {// set rankingif (this.ranking.coeff_date == RankingProfile.COEFF_MAX) {// set a most-recent ordering- params.setSortField(YaCySchema.last_modified.getSolrFieldName(), ORDER.desc);+ params.setSortField(CollectionSchema.last_modified.getSolrFieldName(), ORDER.desc);}}if (fq.length() > 0) {diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.javaindex 62f0b052a..e370448a6 100644--- a/source/net/yacy/search/query/SearchEvent.java+++ b/source/net/yacy/search/query/SearchEvent.java@@ -42,7 +42,6 @@ import net.yacy.cora.date.GenericFormatter;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.analysis.Classification;import net.yacy.cora.document.analysis.Classification.ContentDomain;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.federate.yacy.CacheStrategy;import net.yacy.cora.federate.yacy.Distribution;import net.yacy.cora.lod.vocabulary.Tagging;@@ -78,6 +77,7 @@ import net.yacy.repository.LoaderDispatcher;import net.yacy.repository.Blacklist.BlacklistType;import net.yacy.search.EventTracker;import net.yacy.search.Switchboard;+import net.yacy.search.schema.CollectionSchema;import net.yacy.search.snippet.ResultEntry;public final class SearchEvent {@@ -497,7 +497,7 @@ public final class SearchEvent {// collect navigation informationReversibleScoreMap<String> fcts;if (this.hostNavigator != null) {- fcts = facets.get(YaCySchema.host_s.getSolrFieldName());+ fcts = facets.get(CollectionSchema.host_s.getSolrFieldName());if (fcts != null) {for (String host: fcts) {int hc = fcts.get(host);@@ -510,7 +510,7 @@ public final class SearchEvent {}if (this.filetypeNavigator != null) {- fcts = facets.get(YaCySchema.url_file_ext_s.getSolrFieldName());+ fcts = facets.get(CollectionSchema.url_file_ext_s.getSolrFieldName());if (fcts != null) {// remove all filetypes that we don't knowIterator<String> i = fcts.iterator();@@ -526,12 +526,12 @@ public final class SearchEvent {}if (this.authorNavigator != null) {- fcts = facets.get(YaCySchema.author_sxt.getSolrFieldName());+ fcts = facets.get(CollectionSchema.author_sxt.getSolrFieldName());if (fcts != null) this.authorNavigator.inc(fcts);}if (this.protocolNavigator != null) {- fcts = facets.get(YaCySchema.url_protocol_s.getSolrFieldName());+ fcts = facets.get(CollectionSchema.url_protocol_s.getSolrFieldName());if (fcts != null) {// remove all protocols that we don't knowIterator<String> i = fcts.iterator();@@ -545,7 +545,7 @@ public final class SearchEvent {// get the vocabulary navigationfor (Tagging v: LibraryProvider.autotagging.getVocabularies()) {- fcts = facets.get(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX);+ fcts = facets.get(CollectionSchema.VOCABULARY_PREFIX + v.getName() + CollectionSchema.VOCABULARY_SUFFIX);if (fcts != null) {ScoreMap<String> vocNav = this.vocabularyNavigator.get(v.getName());if (vocNav == null) {diff --git a/source/net/yacy/search/index/SolrConfiguration.java b/source/net/yacy/search/schema/CollectionConfiguration.javasimilarity index 57%rename from source/net/yacy/search/index/SolrConfiguration.javarename to source/net/yacy/search/schema/CollectionConfiguration.javaindex ff6d60200..3f01e1e59 100644--- a/source/net/yacy/search/index/SolrConfiguration.java+++ b/source/net/yacy/search/schema/CollectionConfiguration.java@@ -1,5 +1,5 @@/**- * SolrConfiguration+ * CollectionConfiguration* Copyright 2011 by Michael Peter Christen* First released 14.04.2011 at http://yacy.net*@@ -22,7 +22,7 @@* If not, see <http://www.gnu.org/licenses/>.*/-package net.yacy.search.index;+package net.yacy.search.schema;import java.io.File;import java.io.IOException;@@ -44,10 +44,10 @@ import java.util.Set;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;+import net.yacy.cora.federate.solr.SchemaConfiguration;import net.yacy.cora.federate.solr.FailType;import net.yacy.cora.federate.solr.ProcessType;-import net.yacy.cora.federate.solr.YaCySchema;-import net.yacy.cora.federate.yacy.ConfigurationSet;+import net.yacy.cora.federate.solr.SchemaDeclaration;import net.yacy.cora.protocol.Domains;import net.yacy.cora.protocol.HeaderFramework;import net.yacy.cora.protocol.ResponseHeader;@@ -73,19 +73,17 @@ import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrInputDocument;-public class SolrConfiguration extends ConfigurationSet implements Serializable {+public class CollectionConfiguration extends SchemaConfiguration implements Serializable {private static final long serialVersionUID=-499100932212840385L;- private boolean lazy;/*** initialize with an empty ConfigurationSet which will cause that all the index* attributes are used*/- public SolrConfiguration() {+ public CollectionConfiguration() {super();- this.lazy = false;}/**@@ -94,112 +92,41 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable* or keyword = value lines (while value is a custom Solr field name* @param configurationFile*/- public SolrConfiguration(final File configurationFile, boolean lazy) {+ public CollectionConfiguration(final File configurationFile, boolean lazy) {super(configurationFile);- this.lazy = lazy;+ super.lazy = lazy;// check consistency: compare with YaCyField enumif (this.isEmpty()) return;Iterator<Entry> it = this.entryIterator();- for (ConfigurationSet.Entry etr = it.next(); it.hasNext(); etr = it.next()) {+ for (SchemaConfiguration.Entry etr = it.next(); it.hasNext(); etr = it.next()) {try {- YaCySchema f = YaCySchema.valueOf(etr.key());+ CollectionSchema f = CollectionSchema.valueOf(etr.key());f.setSolrFieldName(etr.getValue());} catch (IllegalArgumentException e) {- Log.logFine("SolrSchema", "solr schema file " + configurationFile.getAbsolutePath() + " defines unknown attribute '" + etr.toString() + "'");+ Log.logFine("SolrCollectionWriter", "solr schema file " + configurationFile.getAbsolutePath() + " defines unknown attribute '" + etr.toString() + "'");it.remove();}}// check consistency the other way: look if all enum constants in SolrField appear in the configuration file- for (YaCySchema field: YaCySchema.values()) {+ for (CollectionSchema field: CollectionSchema.values()) {if (this.get(field.name()) == null) {- Log.logWarning("SolrSchema", " solr schema file " + configurationFile.getAbsolutePath() + " is missing declaration for '" + field.name() + "'");+ Log.logWarning("SolrCollectionWriter", " solr schema file " + configurationFile.getAbsolutePath() + " is missing declaration for '" + field.name() + "'");}}}-- /**- * Convert a SolrDocument to a SolrInputDocument.- * This is useful if a document from the search index shall be modified and indexed again.- * This shall be used as replacement of ClientUtils.toSolrInputDocument because we remove some fields- * which are created automatically during the indexing process.- * @param doc the solr document- * @return a solr input document- */- public SolrInputDocument toSolrInputDocument(SolrDocument doc) {- SolrInputDocument sid = new SolrInputDocument();- Set<String> omitFields = new HashSet<String>();- omitFields.add(YaCySchema.coordinate_p.getSolrFieldName() + "_0_coordinate");- omitFields.add(YaCySchema.coordinate_p.getSolrFieldName() + "_1_coordinate");- omitFields.add(YaCySchema.author_sxt.getSolrFieldName());- for (String name: doc.getFieldNames()) {- if (this.contains(name) && !omitFields.contains(name)) sid.addField(name, doc.getFieldValue(name), 1.0f);- }- return sid;- }-- public boolean contains(YaCySchema field) {- return this.contains(field.name());- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final String value) {- assert !key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && !value.isEmpty()))) key.add(doc, value);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final Date value) {- assert !key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && value.getTime() > 0))) key.add(doc, value);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final String[] value) {- assert key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && value.length > 0))) key.add(doc, value);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final Integer[] value) {- assert key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || (value != null && value.length > 0))) key.add(doc, value);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final List<?> values) {- assert key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || (values != null && !values.isEmpty()))) key.add(doc, values);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final int value) {- assert !key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || value != 0)) key.add(doc, value);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final long value) {- assert !key.isMultiValued();- if ((isEmpty() || contains(key)) && (!this.lazy || value != 0)) key.add(doc, value);- }-- private void add(final SolrInputDocument doc, final YaCySchema key, final boolean value) {- assert !key.isMultiValued();- if (isEmpty() || contains(key)) key.add(doc, value);- }-- protected static Date getDate(SolrInputDocument doc, final YaCySchema key) {- Date x = (Date) doc.getFieldValue(key.getSolrFieldName());- Date now = new Date();- return (x == null) ? new Date(0) : x.after(now) ? now : x;- }/*** save configuration to file and update enum SolrFields* @throws IOException*/- @Overridepublic void commit() throws IOException {try {super.commit();// make sure the enum SolrField.SolrFieldName is currentIterator<Entry> it = this.entryIterator();- for (ConfigurationSet.Entry etr = it.next(); it.hasNext(); etr = it.next()) {+ for (SchemaConfiguration.Entry etr = it.next(); it.hasNext(); etr = it.next()) {try {- YaCySchema f = YaCySchema.valueOf(etr.key());+ SchemaDeclaration f = CollectionSchema.valueOf(etr.key());f.setSolrFieldName(etr.getValue());} catch (IllegalArgumentException e) {continue;@@ -208,30 +135,50 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable} catch (final IOException e) {}}- protected SolrInputDocument metadata2solr(final URIMetadataRow md) {+ /**+ * Convert a SolrDocument to a SolrInputDocument.+ * This is useful if a document from the search index shall be modified and indexed again.+ * This shall be used as replacement of ClientUtils.toSolrInputDocument because we remove some fields+ * which are created automatically during the indexing process.+ * @param doc the solr document+ * @return a solr input document+ */+ public SolrInputDocument toSolrInputDocument(SolrDocument doc) {+ SolrInputDocument sid = new SolrInputDocument();+ Set<String> omitFields = new HashSet<String>();+ omitFields.add(CollectionSchema.coordinate_p.getSolrFieldName() + "_0_coordinate");+ omitFields.add(CollectionSchema.coordinate_p.getSolrFieldName() + "_1_coordinate");+ omitFields.add(CollectionSchema.author_sxt.getSolrFieldName());+ for (String name: doc.getFieldNames()) {+ if (this.contains(name) && !omitFields.contains(name)) sid.addField(name, doc.getFieldValue(name), 1.0f);+ }+ return sid;+ }++ public SolrInputDocument metadata2solr(final URIMetadataRow md) {final SolrInputDocument doc = new SolrInputDocument();final DigestURI digestURI = DigestURI.toDigestURI(md.url());boolean allAttr = this.isEmpty();- if (allAttr || contains(YaCySchema.failreason_t)) add(doc, YaCySchema.failreason_t, "");- add(doc, YaCySchema.id, ASCII.String(md.hash()));+ if (allAttr || contains(CollectionSchema.failreason_t)) add(doc, CollectionSchema.failreason_t, "");+ add(doc, CollectionSchema.id, ASCII.String(md.hash()));String us = digestURI.toNormalform(true);- add(doc, YaCySchema.sku, us);- if (allAttr || contains(YaCySchema.ip_s)) {+ add(doc, CollectionSchema.sku, us);+ if (allAttr || contains(CollectionSchema.ip_s)) {final InetAddress address = digestURI.getInetAddress();- if (address != null) add(doc, YaCySchema.ip_s, address.getHostAddress());+ if (address != null) add(doc, CollectionSchema.ip_s, address.getHostAddress());}- if (allAttr || contains(YaCySchema.url_protocol_s)) add(doc, YaCySchema.url_protocol_s, digestURI.getProtocol());+ if (allAttr || contains(CollectionSchema.url_protocol_s)) add(doc, CollectionSchema.url_protocol_s, digestURI.getProtocol());Map<String, String> searchpart = digestURI.getSearchpartMap();if (searchpart == null) {- if (allAttr || contains(YaCySchema.url_parameter_i)) add(doc, YaCySchema.url_parameter_i, 0);+ if (allAttr || contains(CollectionSchema.url_parameter_i)) add(doc, CollectionSchema.url_parameter_i, 0);} else {- if (allAttr || contains(YaCySchema.url_parameter_i)) add(doc, YaCySchema.url_parameter_i, searchpart.size());- if (allAttr || contains(YaCySchema.url_parameter_key_sxt)) add(doc, YaCySchema.url_parameter_key_sxt, searchpart.keySet().toArray(new String[searchpart.size()]));- if (allAttr || contains(YaCySchema.url_parameter_value_sxt)) add(doc, YaCySchema.url_parameter_value_sxt, searchpart.values().toArray(new String[searchpart.size()]));+ if (allAttr || contains(CollectionSchema.url_parameter_i)) add(doc, CollectionSchema.url_parameter_i, searchpart.size());+ if (allAttr || contains(CollectionSchema.url_parameter_key_sxt)) add(doc, CollectionSchema.url_parameter_key_sxt, searchpart.keySet().toArray(new String[searchpart.size()]));+ if (allAttr || contains(CollectionSchema.url_parameter_value_sxt)) add(doc, CollectionSchema.url_parameter_value_sxt, searchpart.values().toArray(new String[searchpart.size()]));}- if (allAttr || contains(YaCySchema.url_chars_i)) add(doc, YaCySchema.url_chars_i, us.length());+ if (allAttr || contains(CollectionSchema.url_chars_i)) add(doc, CollectionSchema.url_chars_i, us.length());String host = null;if ((host = digestURI.getHost()) != null) {String dnc = Domains.getDNC(host);@@ -239,41 +186,41 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableint p = subdomOrga.lastIndexOf('.');String subdom = (p < 0) ? "" : subdomOrga.substring(0, p);String orga = (p < 0) ? subdomOrga : subdomOrga.substring(p + 1);- if (allAttr || contains(YaCySchema.host_s)) add(doc, YaCySchema.host_s, host);- if (allAttr || contains(YaCySchema.host_dnc_s)) add(doc, YaCySchema.host_dnc_s, dnc);- if (allAttr || contains(YaCySchema.host_organization_s)) add(doc, YaCySchema.host_organization_s, orga);- if (allAttr || contains(YaCySchema.host_organizationdnc_s)) add(doc, YaCySchema.host_organizationdnc_s, orga + '.' + dnc);- if (allAttr || contains(YaCySchema.host_subdomain_s)) add(doc, YaCySchema.host_subdomain_s, subdom);+ if (allAttr || contains(CollectionSchema.host_s)) add(doc, CollectionSchema.host_s, host);+ if (allAttr || contains(CollectionSchema.host_dnc_s)) add(doc, CollectionSchema.host_dnc_s, dnc);+ if (allAttr || contains(CollectionSchema.host_organization_s)) add(doc, CollectionSchema.host_organization_s, orga);+ if (allAttr || contains(CollectionSchema.host_organizationdnc_s)) add(doc, CollectionSchema.host_organizationdnc_s, orga + '.' + dnc);+ if (allAttr || contains(CollectionSchema.host_subdomain_s)) add(doc, CollectionSchema.host_subdomain_s, subdom);}String title = md.dc_title();- if (allAttr || contains(YaCySchema.title)) add(doc, YaCySchema.title, new String[]{title});- if (allAttr || contains(YaCySchema.title_count_i)) add(doc, YaCySchema.title_count_i, 1);- if (allAttr || contains(YaCySchema.title_chars_val)) {+ if (allAttr || contains(CollectionSchema.title)) add(doc, CollectionSchema.title, new String[]{title});+ if (allAttr || contains(CollectionSchema.title_count_i)) add(doc, CollectionSchema.title_count_i, 1);+ if (allAttr || contains(CollectionSchema.title_chars_val)) {Integer[] cv = new Integer[]{new Integer(title.length())};- add(doc, YaCySchema.title_chars_val, cv);+ add(doc, CollectionSchema.title_chars_val, cv);}- if (allAttr || contains(YaCySchema.title_words_val)) {+ if (allAttr || contains(CollectionSchema.title_words_val)) {Integer[] cv = new Integer[]{new Integer(CommonPattern.SPACE.split(title).length)};- add(doc, YaCySchema.title_words_val, cv);+ add(doc, CollectionSchema.title_words_val, cv);}String description = md.snippet(); if (description == null) description = "";- if (allAttr || contains(YaCySchema.description)) add(doc, YaCySchema.description, description);- if (allAttr || contains(YaCySchema.description_count_i)) add(doc, YaCySchema.description_count_i, 1);- if (allAttr || contains(YaCySchema.description_chars_val)) {+ if (allAttr || contains(CollectionSchema.description)) add(doc, CollectionSchema.description, description);+ if (allAttr || contains(CollectionSchema.description_count_i)) add(doc, CollectionSchema.description_count_i, 1);+ if (allAttr || contains(CollectionSchema.description_chars_val)) {Integer[] cv = new Integer[]{new Integer(description.length())};- add(doc, YaCySchema.description_chars_val, cv);+ add(doc, CollectionSchema.description_chars_val, cv);}- if (allAttr || contains(YaCySchema.description_words_val)) {+ if (allAttr || contains(CollectionSchema.description_words_val)) {Integer[] cv = new Integer[]{new Integer(CommonPattern.SPACE.split(description).length)};- add(doc, YaCySchema.description_words_val, cv);+ add(doc, CollectionSchema.description_words_val, cv);}- if (allAttr || contains(YaCySchema.author)) add(doc, YaCySchema.author, md.dc_creator());- if (allAttr || contains(YaCySchema.content_type)) add(doc, YaCySchema.content_type, Response.doctype2mime(digestURI.getFileExtension(), md.doctype()));- if (allAttr || contains(YaCySchema.last_modified)) add(doc, YaCySchema.last_modified, md.moddate());- if (allAttr || contains(YaCySchema.wordcount_i)) add(doc, YaCySchema.wordcount_i, md.wordCount());+ if (allAttr || contains(CollectionSchema.author)) add(doc, CollectionSchema.author, md.dc_creator());+ if (allAttr || contains(CollectionSchema.content_type)) add(doc, CollectionSchema.content_type, Response.doctype2mime(digestURI.getFileExtension(), md.doctype()));+ if (allAttr || contains(CollectionSchema.last_modified)) add(doc, CollectionSchema.last_modified, md.moddate());+ if (allAttr || contains(CollectionSchema.wordcount_i)) add(doc, CollectionSchema.wordcount_i, md.wordCount());String keywords = md.dc_subject();Bitfield flags = md.flags();@@ -282,38 +229,38 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableif (keywords.indexOf(',') > 0) keywords += ", indexof"; else keywords += " indexof";}}- if (allAttr || contains(YaCySchema.keywords)) {- add(doc, YaCySchema.keywords, keywords);+ if (allAttr || contains(CollectionSchema.keywords)) {+ add(doc, CollectionSchema.keywords, keywords);}// path elements of link- if (allAttr || contains(YaCySchema.url_paths_sxt)) add(doc, YaCySchema.url_paths_sxt, digestURI.getPaths());- if (allAttr || contains(YaCySchema.url_file_ext_s)) add(doc, YaCySchema.url_file_ext_s, digestURI.getFileExtension());+ if (allAttr || contains(CollectionSchema.url_paths_sxt)) add(doc, CollectionSchema.url_paths_sxt, digestURI.getPaths());+ if (allAttr || contains(CollectionSchema.url_file_ext_s)) add(doc, CollectionSchema.url_file_ext_s, digestURI.getFileExtension());- if (allAttr || contains(YaCySchema.imagescount_i)) add(doc, YaCySchema.imagescount_i, md.limage());- if (allAttr || contains(YaCySchema.inboundlinkscount_i)) add(doc, YaCySchema.inboundlinkscount_i, md.llocal());- if (allAttr || contains(YaCySchema.outboundlinkscount_i)) add(doc, YaCySchema.outboundlinkscount_i, md.lother());- if (allAttr || contains(YaCySchema.charset_s)) add(doc, YaCySchema.charset_s, "UTF8");+ if (allAttr || contains(CollectionSchema.imagescount_i)) add(doc, CollectionSchema.imagescount_i, md.limage());+ if (allAttr || contains(CollectionSchema.inboundlinkscount_i)) add(doc, CollectionSchema.inboundlinkscount_i, md.llocal());+ if (allAttr || contains(CollectionSchema.outboundlinkscount_i)) add(doc, CollectionSchema.outboundlinkscount_i, md.lother());+ if (allAttr || contains(CollectionSchema.charset_s)) add(doc, CollectionSchema.charset_s, "UTF8");// coordinatesif (md.lat() != 0.0 && md.lon() != 0.0) {- if (allAttr || contains(YaCySchema.coordinate_p)) add(doc, YaCySchema.coordinate_p, Double.toString(md.lat()) + "," + Double.toString(md.lon()));+ if (allAttr || contains(CollectionSchema.coordinate_p)) add(doc, CollectionSchema.coordinate_p, Double.toString(md.lat()) + "," + Double.toString(md.lon()));}- if (allAttr || contains(YaCySchema.httpstatus_i)) add(doc, YaCySchema.httpstatus_i, 200);+ if (allAttr || contains(CollectionSchema.httpstatus_i)) add(doc, CollectionSchema.httpstatus_i, 200);// fields that are in URIMetadataRow additional to yacy2solr basic requirement- if (allAttr || contains(YaCySchema.load_date_dt)) add(doc, YaCySchema.load_date_dt, md.loaddate());- if (allAttr || contains(YaCySchema.fresh_date_dt)) add(doc, YaCySchema.fresh_date_dt, md.freshdate());- if (allAttr || contains(YaCySchema.host_id_s)) add(doc, YaCySchema.host_id_s, md.hosthash());- if ((allAttr || contains(YaCySchema.referrer_id_txt)) && md.referrerHash() != null) add(doc, YaCySchema.referrer_id_txt, new String[]{ASCII.String(md.referrerHash())});- if (allAttr || contains(YaCySchema.md5_s)) add(doc, YaCySchema.md5_s, md.md5());- if (allAttr || contains(YaCySchema.publisher_t)) add(doc, YaCySchema.publisher_t, md.dc_publisher());- if ((allAttr || contains(YaCySchema.language_s)) && md.language() != null) add(doc, YaCySchema.language_s, UTF8.String(md.language()));- if (allAttr || contains(YaCySchema.size_i)) add(doc, YaCySchema.size_i, md.size());- if (allAttr || contains(YaCySchema.audiolinkscount_i)) add(doc, YaCySchema.audiolinkscount_i, md.laudio());- if (allAttr || contains(YaCySchema.videolinkscount_i)) add(doc, YaCySchema.videolinkscount_i, md.lvideo());- if (allAttr || contains(YaCySchema.applinkscount_i)) add(doc, YaCySchema.applinkscount_i, md.lapp());- if (allAttr || contains(YaCySchema.text_t)) {+ if (allAttr || contains(CollectionSchema.load_date_dt)) add(doc, CollectionSchema.load_date_dt, md.loaddate());+ if (allAttr || contains(CollectionSchema.fresh_date_dt)) add(doc, CollectionSchema.fresh_date_dt, md.freshdate());+ if (allAttr || contains(CollectionSchema.host_id_s)) add(doc, CollectionSchema.host_id_s, md.hosthash());+ if ((allAttr || contains(CollectionSchema.referrer_id_txt)) && md.referrerHash() != null) add(doc, CollectionSchema.referrer_id_txt, new String[]{ASCII.String(md.referrerHash())});+ if (allAttr || contains(CollectionSchema.md5_s)) add(doc, CollectionSchema.md5_s, md.md5());+ if (allAttr || contains(CollectionSchema.publisher_t)) add(doc, CollectionSchema.publisher_t, md.dc_publisher());+ if ((allAttr || contains(CollectionSchema.language_s)) && md.language() != null) add(doc, CollectionSchema.language_s, UTF8.String(md.language()));+ if (allAttr || contains(CollectionSchema.size_i)) add(doc, CollectionSchema.size_i, md.size());+ if (allAttr || contains(CollectionSchema.audiolinkscount_i)) add(doc, CollectionSchema.audiolinkscount_i, md.laudio());+ if (allAttr || contains(CollectionSchema.videolinkscount_i)) add(doc, CollectionSchema.videolinkscount_i, md.lvideo());+ if (allAttr || contains(CollectionSchema.applinkscount_i)) add(doc, CollectionSchema.applinkscount_i, md.lapp());+ if (allAttr || contains(CollectionSchema.text_t)) {// construct the text from other metadata parts.// This is necessary here since that is used to search the link when no other data (parsed text body) is availableStringBuilder sb = new StringBuilder(120);@@ -323,7 +270,7 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableaccText(sb, md.snippet());accText(sb, digestURI.toTokens());accText(sb, keywords);- add(doc, YaCySchema.text_t, sb.toString());+ add(doc, CollectionSchema.text_t, sb.toString());}return doc;@@ -336,7 +283,7 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableif (!text.isEmpty() && text.charAt(text.length() - 1) == '.') sb.append(text); else sb.append(text).append('.');}- protected SolrInputDocument yacy2solr(+ public SolrInputDocument yacy2solr(final String id, final CrawlProfile profile, final ResponseHeader responseHeader,final Document document, Condenser condenser, DigestURI referrerURL, String language,IndexCell<CitationReference> citations) {@@ -347,15 +294,15 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableSet<ProcessType> processTypes = new LinkedHashSet<ProcessType>();- add(doc, YaCySchema.id, id);- if (allAttr || contains(YaCySchema.failreason_t)) add(doc, YaCySchema.failreason_t, ""); // overwrite a possible fail reason (in case that there was a fail reason before)+ add(doc, CollectionSchema.id, id);+ if (allAttr || contains(CollectionSchema.failreason_t)) add(doc, CollectionSchema.failreason_t, ""); // overwrite a possible fail reason (in case that there was a fail reason before)String docurl = digestURI.toNormalform(true);- add(doc, YaCySchema.sku, docurl);+ add(doc, CollectionSchema.sku, docurl);- if ((allAttr || contains(YaCySchema.clickdepth_i)) && citations != null) {+ if ((allAttr || contains(CollectionSchema.clickdepth_i)) && citations != null) {if (digestURI.probablyRootURL()) {boolean lc = this.lazy; this.lazy = false;- add(doc, YaCySchema.clickdepth_i, 0);+ add(doc, CollectionSchema.clickdepth_i, 0);this.lazy = lc;} else {// search the citations for references@@ -363,30 +310,30 @@ public class SolrConfiguration extends ConfigurationSet implements Serializabletry {clickdepth = getClickDepth(citations, digestURI);} catch (IOException e) {- add(doc, YaCySchema.clickdepth_i, -1);+ add(doc, CollectionSchema.clickdepth_i, -1);}- add(doc, YaCySchema.clickdepth_i, clickdepth);+ add(doc, CollectionSchema.clickdepth_i, clickdepth);if (clickdepth < 0 || clickdepth > 1) {processTypes.add(ProcessType.CLICKDEPTH); // postprocessing needed; this is also needed if the depth is positive; there could be a shortcut}}}- if (allAttr || contains(YaCySchema.ip_s)) {+ if (allAttr || contains(CollectionSchema.ip_s)) {final InetAddress address = digestURI.getInetAddress();- if (address != null) add(doc, YaCySchema.ip_s, address.getHostAddress());+ if (address != null) add(doc, CollectionSchema.ip_s, address.getHostAddress());}- if (allAttr || contains(YaCySchema.collection_sxt) && profile != null) add(doc, YaCySchema.collection_sxt, profile.collections());- if (allAttr || contains(YaCySchema.url_protocol_s)) add(doc, YaCySchema.url_protocol_s, digestURI.getProtocol());+ if (allAttr || contains(CollectionSchema.collection_sxt) && profile != null) add(doc, CollectionSchema.collection_sxt, profile.collections());+ if (allAttr || contains(CollectionSchema.url_protocol_s)) add(doc, CollectionSchema.url_protocol_s, digestURI.getProtocol());Map<String, String> searchpart = digestURI.getSearchpartMap();if (searchpart == null) {- if (allAttr || contains(YaCySchema.url_parameter_i)) add(doc, YaCySchema.url_parameter_i, 0);+ if (allAttr || contains(CollectionSchema.url_parameter_i)) add(doc, CollectionSchema.url_parameter_i, 0);} else {- if (allAttr || contains(YaCySchema.url_parameter_i)) add(doc, YaCySchema.url_parameter_i, searchpart.size());- if (allAttr || contains(YaCySchema.url_parameter_key_sxt)) add(doc, YaCySchema.url_parameter_key_sxt, searchpart.keySet().toArray(new String[searchpart.size()]));- if (allAttr || contains(YaCySchema.url_parameter_value_sxt)) add(doc, YaCySchema.url_parameter_value_sxt, searchpart.values().toArray(new String[searchpart.size()]));+ if (allAttr || contains(CollectionSchema.url_parameter_i)) add(doc, CollectionSchema.url_parameter_i, searchpart.size());+ if (allAttr || contains(CollectionSchema.url_parameter_key_sxt)) add(doc, CollectionSchema.url_parameter_key_sxt, searchpart.keySet().toArray(new String[searchpart.size()]));+ if (allAttr || contains(CollectionSchema.url_parameter_value_sxt)) add(doc, CollectionSchema.url_parameter_value_sxt, searchpart.values().toArray(new String[searchpart.size()]));}- if (allAttr || contains(YaCySchema.url_chars_i)) add(doc, YaCySchema.url_chars_i, docurl.length());+ if (allAttr || contains(CollectionSchema.url_chars_i)) add(doc, CollectionSchema.url_chars_i, docurl.length());String host = null;if ((host = digestURI.getHost()) != null) {String dnc = Domains.getDNC(host);@@ -394,78 +341,78 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableint p = subdomOrga.lastIndexOf('.');String subdom = (p < 0) ? "" : subdomOrga.substring(0, p);String orga = (p < 0) ? subdomOrga : subdomOrga.substring(p + 1);- if (allAttr || contains(YaCySchema.host_s)) add(doc, YaCySchema.host_s, host);- if (allAttr || contains(YaCySchema.host_dnc_s)) add(doc, YaCySchema.host_dnc_s, dnc);- if (allAttr || contains(YaCySchema.host_organization_s)) add(doc, YaCySchema.host_organization_s, orga);- if (allAttr || contains(YaCySchema.host_organizationdnc_s)) add(doc, YaCySchema.host_organizationdnc_s, orga + '.' + dnc);- if (allAttr || contains(YaCySchema.host_subdomain_s)) add(doc, YaCySchema.host_subdomain_s, subdom);+ if (allAttr || contains(CollectionSchema.host_s)) add(doc, CollectionSchema.host_s, host);+ if (allAttr || contains(CollectionSchema.host_dnc_s)) add(doc, CollectionSchema.host_dnc_s, dnc);+ if (allAttr || contains(CollectionSchema.host_organization_s)) add(doc, CollectionSchema.host_organization_s, orga);+ if (allAttr || contains(CollectionSchema.host_organizationdnc_s)) add(doc, CollectionSchema.host_organizationdnc_s, orga + '.' + dnc);+ if (allAttr || contains(CollectionSchema.host_subdomain_s)) add(doc, CollectionSchema.host_subdomain_s, subdom);}List<String> titles = document.titles();- if (allAttr || contains(YaCySchema.title)) add(doc, YaCySchema.title, titles);- if (allAttr || contains(YaCySchema.title_count_i)) add(doc, YaCySchema.title_count_i, titles.size());- if (allAttr || contains(YaCySchema.title_chars_val)) {+ if (allAttr || contains(CollectionSchema.title)) add(doc, CollectionSchema.title, titles);+ if (allAttr || contains(CollectionSchema.title_count_i)) add(doc, CollectionSchema.title_count_i, titles.size());+ if (allAttr || contains(CollectionSchema.title_chars_val)) {ArrayList<Integer> cv = new ArrayList<Integer>(titles.size());for (String s: titles) cv.add(new Integer(s.length()));- add(doc, YaCySchema.title_chars_val, cv);+ add(doc, CollectionSchema.title_chars_val, cv);}- if (allAttr || contains(YaCySchema.title_words_val)) {+ if (allAttr || contains(CollectionSchema.title_words_val)) {ArrayList<Integer> cv = new ArrayList<Integer>(titles.size());for (String s: titles) cv.add(new Integer(CommonPattern.SPACE.split(s).length));- add(doc, YaCySchema.title_words_val, cv);+ add(doc, CollectionSchema.title_words_val, cv);}String description = document.dc_description();List<String> descriptions = new ArrayList<String>();for (String s: CommonPattern.NEWLINE.split(description)) descriptions.add(s);- if (allAttr || contains(YaCySchema.description)) add(doc, YaCySchema.description, description);- if (allAttr || contains(YaCySchema.description_count_i)) add(doc, YaCySchema.description_count_i, descriptions.size());- if (allAttr || contains(YaCySchema.description_chars_val)) {+ if (allAttr || contains(CollectionSchema.description)) add(doc, CollectionSchema.description, description);+ if (allAttr || contains(CollectionSchema.description_count_i)) add(doc, CollectionSchema.description_count_i, descriptions.size());+ if (allAttr || contains(CollectionSchema.description_chars_val)) {ArrayList<Integer> cv = new ArrayList<Integer>(descriptions.size());for (String s: descriptions) cv.add(new Integer(s.length()));- add(doc, YaCySchema.description_chars_val, cv);+ add(doc, CollectionSchema.description_chars_val, cv);}- if (allAttr || contains(YaCySchema.description_words_val)) {+ if (allAttr || contains(CollectionSchema.description_words_val)) {ArrayList<Integer> cv = new ArrayList<Integer>(descriptions.size());for (String s: descriptions) cv.add(new Integer(CommonPattern.SPACE.split(s).length));- add(doc, YaCySchema.description_words_val, cv);+ add(doc, CollectionSchema.description_words_val, cv);}- if (allAttr || contains(YaCySchema.author)) {+ if (allAttr || contains(CollectionSchema.author)) {String author = document.dc_creator();if (author == null || author.length() == 0) author = document.dc_publisher();- add(doc, YaCySchema.author, author);+ add(doc, CollectionSchema.author, author);}- if (allAttr || contains(YaCySchema.content_type)) add(doc, YaCySchema.content_type, new String[]{document.dc_format()});- if (allAttr || contains(YaCySchema.last_modified)) add(doc, YaCySchema.last_modified, responseHeader == null ? new Date() : responseHeader.lastModified());- if (allAttr || contains(YaCySchema.keywords)) add(doc, YaCySchema.keywords, document.dc_subject(' '));+ if (allAttr || contains(CollectionSchema.content_type)) add(doc, CollectionSchema.content_type, new String[]{document.dc_format()});+ if (allAttr || contains(CollectionSchema.last_modified)) add(doc, CollectionSchema.last_modified, responseHeader == null ? new Date() : responseHeader.lastModified());+ if (allAttr || contains(CollectionSchema.keywords)) add(doc, CollectionSchema.keywords, document.dc_subject(' '));String content = document.getTextString();if (content == null || content.length() == 0) {content = digestURI.toTokens();}- if (allAttr || contains(YaCySchema.text_t)) add(doc, YaCySchema.text_t, content);- if (allAttr || contains(YaCySchema.wordcount_i)) {+ if (allAttr || contains(CollectionSchema.text_t)) add(doc, CollectionSchema.text_t, content);+ if (allAttr || contains(CollectionSchema.wordcount_i)) {if (content.length() == 0) {- add(doc, YaCySchema.wordcount_i, 0);+ add(doc, CollectionSchema.wordcount_i, 0);} else {int contentwc = 1;for (int i = content.length() - 1; i >= 0; i--) if (content.charAt(i) == ' ') contentwc++;- add(doc, YaCySchema.wordcount_i, contentwc);+ add(doc, CollectionSchema.wordcount_i, contentwc);}}- if (allAttr || contains(YaCySchema.synonyms_sxt)) {+ if (allAttr || contains(CollectionSchema.synonyms_sxt)) {List<String> synonyms = condenser.synonyms();- add(doc, YaCySchema.synonyms_sxt, synonyms);+ add(doc, CollectionSchema.synonyms_sxt, synonyms);}- add(doc, YaCySchema.exact_signature_l, condenser.exactSignature());- add(doc, YaCySchema.exact_signature_unique_b, true); // this must be corrected afterwards!- add(doc, YaCySchema.fuzzy_signature_l, condenser.fuzzySignature());- add(doc, YaCySchema.fuzzy_signature_text_t, condenser.fuzzySignatureText());- add(doc, YaCySchema.fuzzy_signature_unique_b, true); // this must be corrected afterwards!+ add(doc, CollectionSchema.exact_signature_l, condenser.exactSignature());+ add(doc, CollectionSchema.exact_signature_unique_b, true); // this must be corrected afterwards!+ add(doc, CollectionSchema.fuzzy_signature_l, condenser.fuzzySignature());+ add(doc, CollectionSchema.fuzzy_signature_text_t, condenser.fuzzySignatureText());+ add(doc, CollectionSchema.fuzzy_signature_unique_b, true); // this must be corrected afterwards!// path elements of link- if (allAttr || contains(YaCySchema.url_paths_sxt)) add(doc, YaCySchema.url_paths_sxt, digestURI.getPaths());- if (allAttr || contains(YaCySchema.url_file_ext_s)) add(doc, YaCySchema.url_file_ext_s, digestURI.getFileExtension());+ if (allAttr || contains(CollectionSchema.url_paths_sxt)) add(doc, CollectionSchema.url_paths_sxt, digestURI.getPaths());+ if (allAttr || contains(CollectionSchema.url_file_ext_s)) add(doc, CollectionSchema.url_file_ext_s, digestURI.getFileExtension());// get list of all links; they will be shrinked by urls that appear in other fields of the solr schemaSet<MultiProtocolURI> inboundLinks = document.inboundLinks();@@ -483,22 +430,22 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableint f = 1;String[] hs;- hs = html.getHeadlines(1); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, YaCySchema.h1_txt, hs); add(doc, YaCySchema.h1_i, hs.length);- hs = html.getHeadlines(2); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, YaCySchema.h2_txt, hs); add(doc, YaCySchema.h2_i, hs.length);- hs = html.getHeadlines(3); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, YaCySchema.h3_txt, hs); add(doc, YaCySchema.h3_i, hs.length);- hs = html.getHeadlines(4); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, YaCySchema.h4_txt, hs); add(doc, YaCySchema.h4_i, hs.length);- hs = html.getHeadlines(5); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, YaCySchema.h5_txt, hs); add(doc, YaCySchema.h5_i, hs.length);- hs = html.getHeadlines(6); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, YaCySchema.h6_txt, hs); add(doc, YaCySchema.h6_i, hs.length);+ hs = html.getHeadlines(1); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h1_txt, hs); add(doc, CollectionSchema.h1_i, hs.length);+ hs = html.getHeadlines(2); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h2_txt, hs); add(doc, CollectionSchema.h2_i, hs.length);+ hs = html.getHeadlines(3); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h3_txt, hs); add(doc, CollectionSchema.h3_i, hs.length);+ hs = html.getHeadlines(4); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h4_txt, hs); add(doc, CollectionSchema.h4_i, hs.length);+ hs = html.getHeadlines(5); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h5_txt, hs); add(doc, CollectionSchema.h5_i, hs.length);+ hs = html.getHeadlines(6); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h6_txt, hs); add(doc, CollectionSchema.h6_i, hs.length);- add(doc, YaCySchema.htags_i, h);- add(doc, YaCySchema.schema_org_breadcrumb_i, html.breadcrumbCount());+ add(doc, CollectionSchema.htags_i, h);+ add(doc, CollectionSchema.schema_org_breadcrumb_i, html.breadcrumbCount());// meta tags: Open Graph propertiesString og;- og = html.getMetas().get("og:title"); if (og != null) add(doc, YaCySchema.opengraph_title_t, og);- og = html.getMetas().get("og:type"); if (og != null) add(doc, YaCySchema.opengraph_type_s, og);- og = html.getMetas().get("og:url"); if (og != null) add(doc, YaCySchema.opengraph_url_s, og);- og = html.getMetas().get("og:image"); if (og != null) add(doc, YaCySchema.opengraph_image_s, og);+ og = html.getMetas().get("og:title"); if (og != null) add(doc, CollectionSchema.opengraph_title_t, og);+ og = html.getMetas().get("og:type"); if (og != null) add(doc, CollectionSchema.opengraph_type_s, og);+ og = html.getMetas().get("og:url"); if (og != null) add(doc, CollectionSchema.opengraph_url_s, og);+ og = html.getMetas().get("og:image"); if (og != null) add(doc, CollectionSchema.opengraph_image_s, og);// noindex and nofollow attributes// from HTML (meta-tag in HTML header: robots)@@ -537,40 +484,40 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableif (x_robots_tag.indexOf("nofollow",0) >= 0) b += 2048; // set bit 11if (x_robots_tag.indexOf("unavailable_after",0) >=0) b += 4096; // set bit 12}- add(doc, YaCySchema.robots_i, b);+ add(doc, CollectionSchema.robots_i, b);// meta tags: generatorfinal String generator = html.getMetas().get("generator");- if (generator != null) add(doc, YaCySchema.metagenerator_t, generator);+ if (generator != null) add(doc, CollectionSchema.metagenerator_t, generator);// bold, italicfinal String[] bold = html.getBold();- add(doc, YaCySchema.boldcount_i, bold.length);+ add(doc, CollectionSchema.boldcount_i, bold.length);if (bold.length > 0) {- add(doc, YaCySchema.bold_txt, bold);- if (allAttr || contains(YaCySchema.bold_val)) {- add(doc, YaCySchema.bold_val, html.getBoldCount(bold));+ add(doc, CollectionSchema.bold_txt, bold);+ if (allAttr || contains(CollectionSchema.bold_val)) {+ add(doc, CollectionSchema.bold_val, html.getBoldCount(bold));}}final String[] italic = html.getItalic();- add(doc, YaCySchema.italiccount_i, italic.length);+ add(doc, CollectionSchema.italiccount_i, italic.length);if (italic.length > 0) {- add(doc, YaCySchema.italic_txt, italic);- if (allAttr || contains(YaCySchema.italic_val)) {- add(doc, YaCySchema.italic_val, html.getItalicCount(italic));+ add(doc, CollectionSchema.italic_txt, italic);+ if (allAttr || contains(CollectionSchema.italic_val)) {+ add(doc, CollectionSchema.italic_val, html.getItalicCount(italic));}}final String[] underline = html.getUnderline();- add(doc, YaCySchema.underlinecount_i, underline.length);+ add(doc, CollectionSchema.underlinecount_i, underline.length);if (underline.length > 0) {- add(doc, YaCySchema.underline_txt, underline);- if (allAttr || contains(YaCySchema.underline_val)) {- add(doc, YaCySchema.underline_val, html.getUnderlineCount(underline));+ add(doc, CollectionSchema.underline_txt, underline);+ if (allAttr || contains(CollectionSchema.underline_val)) {+ add(doc, CollectionSchema.underline_val, html.getUnderlineCount(underline));}}final String[] li = html.getLi();- add(doc, YaCySchema.licount_i, li.length);- if (li.length > 0) add(doc, YaCySchema.li_txt, li);+ add(doc, CollectionSchema.licount_i, li.length);+ if (li.length > 0) add(doc, CollectionSchema.li_txt, li);// imagesfinal Collection<ImageEntry> imagesc = images.values();@@ -590,15 +537,15 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableimgalts.add(ie.alt());if (ie.alt() != null && ie.alt().length() > 0) withalt++;}- if (allAttr || contains(YaCySchema.imagescount_i)) add(doc, YaCySchema.imagescount_i, imgtags.size());- if (allAttr || contains(YaCySchema.images_tag_txt)) add(doc, YaCySchema.images_tag_txt, imgtags);- if (allAttr || contains(YaCySchema.images_protocol_sxt)) add(doc, YaCySchema.images_protocol_sxt, protocolList2indexedList(imgprots));- if (allAttr || contains(YaCySchema.images_urlstub_txt)) add(doc, YaCySchema.images_urlstub_txt, imgstubs);- if (allAttr || contains(YaCySchema.images_alt_txt)) add(doc, YaCySchema.images_alt_txt, imgalts);- if (allAttr || contains(YaCySchema.images_withalt_i)) add(doc, YaCySchema.images_withalt_i, withalt);+ if (allAttr || contains(CollectionSchema.imagescount_i)) add(doc, CollectionSchema.imagescount_i, imgtags.size());+ if (allAttr || contains(CollectionSchema.images_tag_txt)) add(doc, CollectionSchema.images_tag_txt, imgtags);+ if (allAttr || contains(CollectionSchema.images_protocol_sxt)) add(doc, CollectionSchema.images_protocol_sxt, protocolList2indexedList(imgprots));+ if (allAttr || contains(CollectionSchema.images_urlstub_txt)) add(doc, CollectionSchema.images_urlstub_txt, imgstubs);+ if (allAttr || contains(CollectionSchema.images_alt_txt)) add(doc, CollectionSchema.images_alt_txt, imgalts);+ if (allAttr || contains(CollectionSchema.images_withalt_i)) add(doc, CollectionSchema.images_withalt_i, withalt);// style sheets- if (allAttr || contains(YaCySchema.css_tag_txt)) {+ if (allAttr || contains(CollectionSchema.css_tag_txt)) {final Map<MultiProtocolURI, String> csss = html.getCSS();final String[] css_tag = new String[csss.size()];final String[] css_url = new String[csss.size()];@@ -613,13 +560,13 @@ public class SolrConfiguration extends ConfigurationSet implements Serializablecss_url[c] = cssurl;c++;}- add(doc, YaCySchema.csscount_i, css_tag.length);- if (css_tag.length > 0) add(doc, YaCySchema.css_tag_txt, css_tag);- if (css_url.length > 0) add(doc, YaCySchema.css_url_txt, css_url);+ add(doc, CollectionSchema.csscount_i, css_tag.length);+ if (css_tag.length > 0) add(doc, CollectionSchema.css_tag_txt, css_tag);+ if (css_url.length > 0) add(doc, CollectionSchema.css_url_txt, css_url);}// Scripts- if (allAttr || contains(YaCySchema.scripts_txt)) {+ if (allAttr || contains(CollectionSchema.scripts_txt)) {final Set<MultiProtocolURI> scriptss = html.getScript();final String[] scripts = new String[scriptss.size()];c = 0;@@ -628,12 +575,12 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableoutboundLinks.remove(u);scripts[c++] = u.toNormalform(false);}- add(doc, YaCySchema.scriptscount_i, scripts.length);- if (scripts.length > 0) add(doc, YaCySchema.scripts_txt, scripts);+ add(doc, CollectionSchema.scriptscount_i, scripts.length);+ if (scripts.length > 0) add(doc, CollectionSchema.scripts_txt, scripts);}// Frames- if (allAttr || contains(YaCySchema.frames_txt)) {+ if (allAttr || contains(CollectionSchema.frames_txt)) {final Set<MultiProtocolURI> framess = html.getFrames();final String[] frames = new String[framess.size()];c = 0;@@ -642,12 +589,12 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableoutboundLinks.remove(u);frames[c++] = u.toNormalform(false);}- add(doc, YaCySchema.framesscount_i, frames.length);- if (frames.length > 0) add(doc, YaCySchema.frames_txt, frames);+ add(doc, CollectionSchema.framesscount_i, frames.length);+ if (frames.length > 0) add(doc, CollectionSchema.frames_txt, frames);}// IFrames- if (allAttr || contains(YaCySchema.iframes_txt)) {+ if (allAttr || contains(CollectionSchema.iframes_txt)) {final Set<MultiProtocolURI> iframess = html.getIFrames();final String[] iframes = new String[iframess.size()];c = 0;@@ -656,26 +603,26 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableoutboundLinks.remove(u);iframes[c++] = u.toNormalform(false);}- add(doc, YaCySchema.iframesscount_i, iframes.length);- if (iframes.length > 0) add(doc, YaCySchema.iframes_txt, iframes);+ add(doc, CollectionSchema.iframesscount_i, iframes.length);+ if (iframes.length > 0) add(doc, CollectionSchema.iframes_txt, iframes);}// canonical tag- if (allAttr || contains(YaCySchema.canonical_t)) {+ if (allAttr || contains(CollectionSchema.canonical_t)) {final MultiProtocolURI canonical = html.getCanonical();if (canonical != null) {inboundLinks.remove(canonical);outboundLinks.remove(canonical);- add(doc, YaCySchema.canonical_t, canonical.toNormalform(false));+ add(doc, CollectionSchema.canonical_t, canonical.toNormalform(false));// set a flag if this is equal to sku- if (contains(YaCySchema.canonical_equal_sku_b) && canonical.equals(docurl)) {- add(doc, YaCySchema.canonical_equal_sku_b, true);+ if (contains(CollectionSchema.canonical_equal_sku_b) && canonical.equals(docurl)) {+ add(doc, CollectionSchema.canonical_equal_sku_b, true);}}}// meta refresh tag- if (allAttr || contains(YaCySchema.refresh_s)) {+ if (allAttr || contains(CollectionSchema.refresh_s)) {String refresh = html.getRefreshPath();if (refresh != null && refresh.length() > 0) {MultiProtocolURI refreshURL;@@ -684,23 +631,23 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableif (refreshURL != null) {inboundLinks.remove(refreshURL);outboundLinks.remove(refreshURL);- add(doc, YaCySchema.refresh_s, refreshURL.toNormalform(false));+ add(doc, CollectionSchema.refresh_s, refreshURL.toNormalform(false));}} catch (MalformedURLException e) {- add(doc, YaCySchema.refresh_s, refresh);+ add(doc, CollectionSchema.refresh_s, refresh);}}}// flash embedded- if (allAttr || contains(YaCySchema.flash_b)) {+ if (allAttr || contains(CollectionSchema.flash_b)) {MultiProtocolURI[] flashURLs = html.getFlash();for (MultiProtocolURI u: flashURLs) {// remove all flash links from ibound/outbound linksinboundLinks.remove(u);outboundLinks.remove(u);}- add(doc, YaCySchema.flash_b, flashURLs.length > 0);+ add(doc, CollectionSchema.flash_b, flashURLs.length > 0);}// generic evaluation pattern@@ -708,21 +655,21 @@ public class SolrConfiguration extends ConfigurationSet implements Serializableif (allAttr || contains("ext_" + model + "_txt")) {final String[] scorenames = html.getEvaluationModelScoreNames(model);if (scorenames.length > 0) {- add(doc, YaCySchema.valueOf("ext_" + model + "_txt"), scorenames);- add(doc, YaCySchema.valueOf("ext_" + model + "_val"), html.getEvaluationModelScoreCounts(model, scorenames));+ add(doc, CollectionSchema.valueOf("ext_" + model + "_txt"), scorenames);+ add(doc, CollectionSchema.valueOf("ext_" + model + "_val"), html.getEvaluationModelScoreCounts(model, scorenames));}}}// response time- add(doc, YaCySchema.responsetime_i, responseHeader == null ? 0 : Integer.parseInt(responseHeader.get(HeaderFramework.RESPONSE_TIME_MILLIS, "0")));+ add(doc, CollectionSchema.responsetime_i, responseHeader == null ? 0 : Integer.parseInt(responseHeader.get(HeaderFramework.RESPONSE_TIME_MILLIS, "0")));}// list all linksfinal Map<MultiProtocolURI, Properties> alllinks = document.getAnchors();c = 0;- if (allAttr || contains(YaCySchema.inboundlinkscount_i)) add(doc, YaCySchema.inboundlinkscount_i, inboundLinks.size());- if (allAttr || contains(YaCySchema.inboundlinksnofollowcount_i)) add(doc, YaCySchema.inboundlinksnofollowcount_i, document.inboundLinkNofollowCount());+ if (allAttr || contains(CollectionSchema.inboundlinkscount_i)) add(doc, CollectionSchema.inboundlinkscount_i, inboundLinks.size());+ if (allAttr || contains(CollectionSchema.inboundlinksnofollowcount_i)) add(doc, CollectionSchema.inboundlinksnofollowcount_i, document.inboundLinkNofollowCount());final List<String> inboundlinksTag = new ArrayList<String>(inboundLinks.size());final List<String> inboundlinksURLProtocol = new ArrayList<String>(inboundLinks.size());final List<String> inboundlinksURLStub = new ArrayList<String>(inboundLinks.size());@@ -757,20 +704,20 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableinboundlinksAltTag.add(ientry == null ? "" : ientry.alt());c++;}- if (allAttr || contains(YaCySchema.inboundlinks_tag_txt)) add(doc, YaCySchema.inboundlinks_tag_txt, inboundlinksTag);- if (allAttr || contains(YaCySchema.inboundlinks_protocol_sxt)) add(doc, YaCySchema.inboundlinks_protocol_sxt, protocolList2indexedList(inboundlinksURLProtocol));- if (allAttr || contains(YaCySchema.inboundlinks_urlstub_txt)) add(doc, YaCySchema.inboundlinks_urlstub_txt, inboundlinksURLStub);- if (allAttr || contains(YaCySchema.inboundlinks_name_txt)) add(doc, YaCySchema.inboundlinks_name_txt, inboundlinksName);- if (allAttr || contains(YaCySchema.inboundlinks_rel_sxt)) add(doc, YaCySchema.inboundlinks_rel_sxt, inboundlinksRel);- if (allAttr || contains(YaCySchema.inboundlinks_relflags_val)) add(doc, YaCySchema.inboundlinks_relflags_val, relEval(inboundlinksRel));- if (allAttr || contains(YaCySchema.inboundlinks_text_txt)) add(doc, YaCySchema.inboundlinks_text_txt, inboundlinksText);- if (allAttr || contains(YaCySchema.inboundlinks_text_chars_val)) add(doc, YaCySchema.inboundlinks_text_chars_val, inboundlinksTextChars);- if (allAttr || contains(YaCySchema.inboundlinks_text_words_val)) add(doc, YaCySchema.inboundlinks_text_words_val, inboundlinksTextWords);- if (allAttr || contains(YaCySchema.inboundlinks_alttag_txt)) add(doc, YaCySchema.inboundlinks_alttag_txt, inboundlinksAltTag);+ if (allAttr || contains(CollectionSchema.inboundlinks_tag_txt)) add(doc, CollectionSchema.inboundlinks_tag_txt, inboundlinksTag);+ if (allAttr || contains(CollectionSchema.inboundlinks_protocol_sxt)) add(doc, CollectionSchema.inboundlinks_protocol_sxt, protocolList2indexedList(inboundlinksURLProtocol));+ if (allAttr || contains(CollectionSchema.inboundlinks_urlstub_txt)) add(doc, CollectionSchema.inboundlinks_urlstub_txt, inboundlinksURLStub);+ if (allAttr || contains(CollectionSchema.inboundlinks_name_txt)) add(doc, CollectionSchema.inboundlinks_name_txt, inboundlinksName);+ if (allAttr || contains(CollectionSchema.inboundlinks_rel_sxt)) add(doc, CollectionSchema.inboundlinks_rel_sxt, inboundlinksRel);+ if (allAttr || contains(CollectionSchema.inboundlinks_relflags_val)) add(doc, CollectionSchema.inboundlinks_relflags_val, relEval(inboundlinksRel));+ if (allAttr || contains(CollectionSchema.inboundlinks_text_txt)) add(doc, CollectionSchema.inboundlinks_text_txt, inboundlinksText);+ if (allAttr || contains(CollectionSchema.inboundlinks_text_chars_val)) add(doc, CollectionSchema.inboundlinks_text_chars_val, inboundlinksTextChars);+ if (allAttr || contains(CollectionSchema.inboundlinks_text_words_val)) add(doc, CollectionSchema.inboundlinks_text_words_val, inboundlinksTextWords);+ if (allAttr || contains(CollectionSchema.inboundlinks_alttag_txt)) add(doc, CollectionSchema.inboundlinks_alttag_txt, inboundlinksAltTag);c = 0;- if (allAttr || contains(YaCySchema.outboundlinkscount_i)) add(doc, YaCySchema.outboundlinkscount_i, outboundLinks.size());- if (allAttr || contains(YaCySchema.outboundlinksnofollowcount_i)) add(doc, YaCySchema.outboundlinksnofollowcount_i, document.outboundLinkNofollowCount());+ if (allAttr || contains(CollectionSchema.outboundlinkscount_i)) add(doc, CollectionSchema.outboundlinkscount_i, outboundLinks.size());+ if (allAttr || contains(CollectionSchema.outboundlinksnofollowcount_i)) add(doc, CollectionSchema.outboundlinksnofollowcount_i, document.outboundLinkNofollowCount());final List<String> outboundlinksTag = new ArrayList<String>(outboundLinks.size());final List<String> outboundlinksURLProtocol = new ArrayList<String>(outboundLinks.size());final List<String> outboundlinksURLStub = new ArrayList<String>(outboundLinks.size());@@ -805,42 +752,42 @@ public class SolrConfiguration extends ConfigurationSet implements SerializableinboundlinksAltTag.add(ientry == null ? "" : ientry.alt());c++;}- if (allAttr || contains(YaCySchema.outboundlinks_tag_txt)) add(doc, YaCySchema.outboundlinks_tag_txt, outboundlinksTag);- if (allAttr || contains(YaCySchema.outboundlinks_protocol_sxt)) add(doc, YaCySchema.outboundlinks_protocol_sxt, protocolList2indexedList(outboundlinksURLProtocol));- if (allAttr || contains(YaCySchema.outboundlinks_urlstub_txt)) add(doc, YaCySchema.outboundlinks_urlstub_txt, outboundlinksURLStub);- if (allAttr || contains(YaCySchema.outboundlinks_name_txt)) add(doc, YaCySchema.outboundlinks_name_txt, outboundlinksName);- if (allAttr || contains(YaCySchema.outboundlinks_rel_sxt)) add(doc, YaCySchema.outboundlinks_rel_sxt, outboundlinksRel);- if (allAttr || contains(YaCySchema.outboundlinks_relflags_val)) add(doc, YaCySchema.outboundlinks_relflags_val, relEval(outboundlinksRel));- if (allAttr || contains(YaCySchema.outboundlinks_text_txt)) add(doc, YaCySchema.outboundlinks_text_txt, outboundlinksText);- if (allAttr || contains(YaCySchema.outboundlinks_text_chars_val)) add(doc, YaCySchema.outboundlinks_text_chars_val, outboundlinksTextChars);- if (allAttr || contains(YaCySchema.outboundlinks_text_words_val)) add(doc, YaCySchema.outboundlinks_text_words_val, outboundlinksTextWords);- if (allAttr || contains(YaCySchema.outboundlinks_alttag_txt)) add(doc, YaCySchema.outboundlinks_alttag_txt, outboundlinksAltTag);+ if (allAttr || contains(CollectionSchema.outboundlinks_tag_txt)) add(doc, CollectionSchema.outboundlinks_tag_txt, outboundlinksTag);+ if (allAttr || contains(CollectionSchema.outboundlinks_protocol_sxt)) add(doc, CollectionSchema.outboundlinks_protocol_sxt, protocolList2indexedList(outboundlinksURLProtocol));+ if (allAttr || contains(CollectionSchema.outboundlinks_urlstub_txt)) add(doc, CollectionSchema.outboundlinks_urlstub_txt, outboundlinksURLStub);+ if (allAttr || contains(CollectionSchema.outboundlinks_name_txt)) add(doc, CollectionSchema.outboundlinks_name_txt, outboundlinksName);+ if (allAttr || contains(CollectionSchema.outboundlinks_rel_sxt)) add(doc, CollectionSchema.outboundlinks_rel_sxt, outboundlinksRel);+ if (allAttr || contains(CollectionSchema.outboundlinks_relflags_val)) add(doc, CollectionSchema.outboundlinks_relflags_val, relEval(outboundlinksRel));+ if (allAttr || contains(CollectionSchema.outboundlinks_text_txt)) add(doc, CollectionSchema.outboundlinks_text_txt, outboundlinksText);+ if (allAttr || contains(CollectionSchema.outboundlinks_text_chars_val)) add(doc, CollectionSchema.outboundlinks_text_chars_val, outboundlinksTextChars);+ if (allAttr || contains(CollectionSchema.outboundlinks_text_words_val)) add(doc, CollectionSchema.outboundlinks_text_words_val, outboundlinksTextWords);+ if (allAttr || contains(CollectionSchema.outboundlinks_alttag_txt)) add(doc, CollectionSchema.outboundlinks_alttag_txt, outboundlinksAltTag);// charset- if (allAttr || contains(YaCySchema.charset_s)) add(doc, YaCySchema.charset_s, document.getCharset());+ if (allAttr || contains(CollectionSchema.charset_s)) add(doc, CollectionSchema.charset_s, document.getCharset());// coordinatesif (document.lat() != 0.0 && document.lon() != 0.0) {- if (allAttr || contains(YaCySchema.coordinate_p)) add(doc, YaCySchema.coordinate_p, Double.toString(document.lat()) + "," + Double.toString(document.lon()));+ if (allAttr || contains(CollectionSchema.coordinate_p)) add(doc, CollectionSchema.coordinate_p, Double.toString(document.lat()) + "," + Double.toString(document.lon()));}- if (allAttr || contains(YaCySchema.httpstatus_i)) add(doc, YaCySchema.httpstatus_i, responseHeader == null ? 200 : responseHeader.getStatusCode());+ if (allAttr || contains(CollectionSchema.httpstatus_i)) add(doc, CollectionSchema.httpstatus_i, responseHeader == null ? 200 : responseHeader.getStatusCode());// fields that were additionally in URIMetadataRowDate loadDate = new Date();Date modDate = responseHeader == null ? new Date() : responseHeader.lastModified();if (modDate.getTime() > loadDate.getTime()) modDate = loadDate;int size = (int) Math.max(document.dc_source().length(), responseHeader == null ? 0 : responseHeader.getContentLength());- if (allAttr || contains(YaCySchema.load_date_dt)) add(doc, YaCySchema.load_date_dt, loadDate);- if (allAttr || contains(YaCySchema.fresh_date_dt)) add(doc, YaCySchema.fresh_date_dt, new Date(loadDate.getTime() + Math.max(0, loadDate.getTime() - modDate.getTime()) / 2)); // freshdate, computed with Proxy-TTL formula- if (allAttr || contains(YaCySchema.host_id_s)) add(doc, YaCySchema.host_id_s, document.dc_source().hosthash());- if ((allAttr || contains(YaCySchema.referrer_id_txt)) && referrerURL != null) add(doc, YaCySchema.referrer_id_txt, new String[]{ASCII.String(referrerURL.hash())});+ if (allAttr || contains(CollectionSchema.load_date_dt)) add(doc, CollectionSchema.load_date_dt, loadDate);+ if (allAttr || contains(CollectionSchema.fresh_date_dt)) add(doc, CollectionSchema.fresh_date_dt, new Date(loadDate.getTime() + Math.max(0, loadDate.getTime() - modDate.getTime()) / 2)); // freshdate, computed with Proxy-TTL formula+ if (allAttr || contains(CollectionSchema.host_id_s)) add(doc, CollectionSchema.host_id_s, document.dc_source().hosthash());+ if ((allAttr || contains(CollectionSchema.referrer_id_txt)) && referrerURL != null) add(doc, CollectionSchema.referrer_id_txt, new String[]{ASCII.String(referrerURL.hash())});//if (allAttr || contains(SolrField.md5_s)) add(solrdoc, SolrField.md5_s, new byte[0]);- if (allAttr || contains(YaCySchema.publisher_t)) add(doc, YaCySchema.publisher_t, document.dc_publisher());- if ((allAttr || contains(YaCySchema.language_s)) && language != null) add(doc, YaCySchema.language_s, language);- if (allAttr || contains(YaCySchema.size_i)) add(doc, YaCySchema.size_i, size);- if (allAttr || contains(YaCySchema.audiolinkscount_i)) add(doc, YaCySchema.audiolinkscount_i, document.getAudiolinks().size());- if (allAttr || contains(YaCySchema.videolinkscount_i)) add(doc, YaCySchema.videolinkscount_i, document.getVideolinks().size());- if (allAttr || contains(YaCySchema.applinkscount_i)) add(doc, YaCySchema.applinkscount_i, document.getApplinks().size());+ if (allAttr || contains(CollectionSchema.publisher_t)) add(doc, CollectionSchema.publisher_t, document.dc_publisher());+ if ((allAttr || contains(CollectionSchema.language_s)) && language != null) add(doc, CollectionSchema.language_s, language);+ if (allAttr || contains(CollectionSchema.size_i)) add(doc, CollectionSchema.size_i, size);+ if (allAttr || contains(CollectionSchema.audiolinkscount_i)) add(doc, CollectionSchema.audiolinkscount_i, document.getAudiolinks().size());+ if (allAttr || contains(CollectionSchema.videolinkscount_i)) add(doc, CollectionSchema.videolinkscount_i, document.getVideolinks().size());+ if (allAttr || contains(CollectionSchema.applinkscount_i)) add(doc, CollectionSchema.applinkscount_i, document.getApplinks().size());// write generic navigation// there are no pre-defined solr fields for navigation because the vocabulary is generic@@ -849,13 +796,13 @@ public class SolrConfiguration extends ConfigurationSet implements Serializablefor (Map.Entry<String, Set<String>> facet: document.getGenericFacets().entrySet()) {String facetName = facet.getKey();Set<String> facetValues = facet.getValue();- doc.setField(YaCySchema.VOCABULARY_PREFIX + facetName + YaCySchema.VOCABULARY_SUFFIX, facetValues.toArray(new String[facetValues.size()]));+ doc.setField(CollectionSchema.VOCABULARY_PREFIX + facetName + CollectionSchema.VOCABULARY_SUFFIX, facetValues.toArray(new String[facetValues.size()]));}- if (allAttr || contains(YaCySchema.process_sxt)) {+ if (allAttr || contains(CollectionSchema.process_sxt)) {List<String> p = new ArrayList<String>();for (ProcessType t: processTypes) p.add(t.name());- add(doc, YaCySchema.process_sxt, p);+ add(doc, CollectionSchema.process_sxt, p);}return doc;}@@ -970,20 +917,20 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable*/public SolrInputDocument err(final DigestURI digestURI, final String failReason, final FailType failType, final int httpstatus) throws IOException {final SolrInputDocument solrdoc = new SolrInputDocument();- add(solrdoc, YaCySchema.id, ASCII.String(digestURI.hash()));- add(solrdoc, YaCySchema.sku, digestURI.toNormalform(true));+ add(solrdoc, CollectionSchema.id, ASCII.String(digestURI.hash()));+ add(solrdoc, CollectionSchema.sku, digestURI.toNormalform(true));final InetAddress address = digestURI.getInetAddress();- if (contains(YaCySchema.ip_s) && address != null) add(solrdoc, YaCySchema.ip_s, address.getHostAddress());- if (contains(YaCySchema.host_s) && digestURI.getHost() != null) add(solrdoc, YaCySchema.host_s, digestURI.getHost());+ if (contains(CollectionSchema.ip_s) && address != null) add(solrdoc, CollectionSchema.ip_s, address.getHostAddress());+ if (contains(CollectionSchema.host_s) && digestURI.getHost() != null) add(solrdoc, CollectionSchema.host_s, digestURI.getHost());// path elements of link- if (contains(YaCySchema.url_paths_sxt)) add(solrdoc, YaCySchema.url_paths_sxt, digestURI.getPaths());- if (contains(YaCySchema.url_file_ext_s)) add(solrdoc, YaCySchema.url_file_ext_s, digestURI.getFileExtension());+ if (contains(CollectionSchema.url_paths_sxt)) add(solrdoc, CollectionSchema.url_paths_sxt, digestURI.getPaths());+ if (contains(CollectionSchema.url_file_ext_s)) add(solrdoc, CollectionSchema.url_file_ext_s, digestURI.getFileExtension());// fail reason and status- if (contains(YaCySchema.failreason_t)) add(solrdoc, YaCySchema.failreason_t, failReason);- if (contains(YaCySchema.failtype_s)) add(solrdoc, YaCySchema.failtype_s, failType.name());- if (contains(YaCySchema.httpstatus_i)) add(solrdoc, YaCySchema.httpstatus_i, httpstatus);+ if (contains(CollectionSchema.failreason_t)) add(solrdoc, CollectionSchema.failreason_t, failReason);+ if (contains(CollectionSchema.failtype_s)) add(solrdoc, CollectionSchema.failtype_s, failType.name());+ if (contains(CollectionSchema.httpstatus_i)) add(solrdoc, CollectionSchema.httpstatus_i, httpstatus);return solrdoc;}diff --git a/source/net/yacy/cora/federate/solr/YaCySchema.java b/source/net/yacy/search/schema/CollectionSchema.javasimilarity index 97%rename from source/net/yacy/cora/federate/solr/YaCySchema.javarename to source/net/yacy/search/schema/CollectionSchema.javaindex 2835b4594..784dedf84 100644--- a/source/net/yacy/cora/federate/solr/YaCySchema.java+++ b/source/net/yacy/search/schema/CollectionSchema.java@@ -1,5 +1,5 @@/**- * YaCySchema+ * CollectionSchema* Copyright 2011 by Michael Peter Christen* First released 14.04.2011 at http://yacy.net*@@ -18,17 +18,17 @@* If not, see <http://www.gnu.org/licenses/>.*/-package net.yacy.cora.federate.solr;+package net.yacy.search.schema;import java.util.Date;-import java.util.HashSet;import java.util.List;-import java.util.Set;-import org.apache.solr.common.SolrDocument;+import net.yacy.cora.federate.solr.SchemaDeclaration;+import net.yacy.cora.federate.solr.SolrType;+import org.apache.solr.common.SolrInputDocument;-public enum YaCySchema implements Schema {+public enum CollectionSchema implements SchemaDeclaration {// mandatoryid(SolrType.string, true, true, false, "primary key of document, the URL hash **mandatory field**"),@@ -202,6 +202,8 @@ public enum YaCySchema implements Schema {ext_title_txt(SolrType.text_general, true, true, true, "names matching title expressions"),ext_title_val(SolrType.num_integer, true, true, true, "number of matching title expressions");+ public final static String CORE_NAME = "collection1";+public final static String VOCABULARY_PREFIX = "vocabulary_";public final static String VOCABULARY_SUFFIX = "_sxt";@@ -211,7 +213,7 @@ public enum YaCySchema implements Schema {private boolean multiValued, omitNorms;private String comment;- private YaCySchema(final SolrType type, final boolean indexed, final boolean stored, final boolean multiValued, final String comment) {+ private CollectionSchema(final SolrType type, final boolean indexed, final boolean stored, final boolean multiValued, final String comment) {this.type = type;this.indexed = indexed;this.stored = stored;@@ -221,12 +223,12 @@ public enum YaCySchema implements Schema {assert type.appropriateName(this.name(), this.multiValued) : "bad configuration: " + this.name();}- private YaCySchema(final SolrType type, final boolean indexed, final boolean stored, final boolean multiValued, final boolean omitNorms, final String comment) {+ private CollectionSchema(final SolrType type, final boolean indexed, final boolean stored, final boolean multiValued, final boolean omitNorms, final String comment) {this(type, indexed, stored, multiValued, comment);this.omitNorms = omitNorms;assert type.appropriateName(this.name(), this.multiValued) : "bad configuration: " + this.name();}-+/*** Returns the YaCy default or (if available) custom field name for Solr* @return SolrFieldname Stringdiff --git a/source/net/yacy/search/schema/WebgraphConfiguration.java b/source/net/yacy/search/schema/WebgraphConfiguration.javanew file mode 100644index 000000000..cb78f65e5--- /dev/null+++ b/source/net/yacy/search/schema/WebgraphConfiguration.java@@ -0,0 +1,100 @@+/**+ * WebgraphConfiguration+ * Copyright 2011 by Michael Peter Christen+ * First released 14.04.2011 at http://yacy.net+ *+ * $LastChangedDate: 2011-04-14 22:05:04 +0200 (Do, 14 Apr 2011) $+ * $LastChangedRevision: 7654 $+ * $LastChangedBy: orbiter $+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.search.schema;++import java.io.File;+import java.io.IOException;+import java.io.Serializable;+import java.util.Iterator;++import net.yacy.cora.federate.solr.SchemaConfiguration;+import net.yacy.cora.federate.solr.SchemaDeclaration;+import net.yacy.kelondro.logging.Log;++public class WebgraphConfiguration extends SchemaConfiguration implements Serializable {++ private static final long serialVersionUID=-499100932212840385L;++ /**+ * initialize with an empty ConfigurationSet which will cause that all the index+ * attributes are used+ */+ public WebgraphConfiguration() {+ super();+ this.lazy = false;+ }++ /**+ * initialize the schema with a given configuration file+ * the configuration file simply contains a list of lines with keywords+ * or keyword = value lines (while value is a custom Solr field name+ * @param configurationFile+ */+ public WebgraphConfiguration(final File configurationFile, boolean lazy) {+ super(configurationFile);+ this.lazy = lazy;+ // check consistency: compare with YaCyField enum+ if (this.isEmpty()) return;+ Iterator<Entry> it = this.entryIterator();+ for (SchemaConfiguration.Entry etr = it.next(); it.hasNext(); etr = it.next()) {+ try {+ WebgraphSchema f = WebgraphSchema.valueOf(etr.key());+ f.setSolrFieldName(etr.getValue());+ } catch (IllegalArgumentException e) {+ Log.logFine("SolrWebgraphWriter", "solr schema file " + configurationFile.getAbsolutePath() + " defines unknown attribute '" + etr.toString() + "'");+ it.remove();+ }+ }+ // check consistency the other way: look if all enum constants in SolrField appear in the configuration file+ for (SchemaDeclaration field: WebgraphSchema.values()) {+ if (this.get(field.name()) == null) {+ Log.logWarning("SolrWebgraphWriter", " solr schema file " + configurationFile.getAbsolutePath() + " is missing declaration for '" + field.name() + "'");+ }+ }+ }+++ /**+ * save configuration to file and update enum SolrFields+ * @throws IOException+ */+ @Override+ public void commit() throws IOException {+ try {+ super.commit();+ // make sure the enum SolrField.SolrFieldName is current+ Iterator<Entry> it = this.entryIterator();+ for (SchemaConfiguration.Entry etr = it.next(); it.hasNext(); etr = it.next()) {+ try {+ SchemaDeclaration f = WebgraphSchema.valueOf(etr.key());+ f.setSolrFieldName(etr.getValue());+ } catch (IllegalArgumentException e) {+ continue;+ }+ }+ } catch (final IOException e) {}+ }++}diff --git a/source/net/yacy/search/schema/WebgraphSchema.java b/source/net/yacy/search/schema/WebgraphSchema.javanew file mode 100644index 000000000..74a21ddf9--- /dev/null+++ b/source/net/yacy/search/schema/WebgraphSchema.java@@ -0,0 +1,239 @@+/**+ * WebgraphSchema+ * Copyright 2011 by Michael Peter Christen+ * First released 19.02.2013 at http://yacy.net+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with this program in the file lgpl21.txt+ * If not, see <http://www.gnu.org/licenses/>.+ */++package net.yacy.search.schema;++import java.util.Date;+import java.util.List;++import net.yacy.cora.federate.solr.SchemaDeclaration;+import net.yacy.cora.federate.solr.SolrType;++import org.apache.solr.common.SolrInputDocument;++public enum WebgraphSchema implements SchemaDeclaration {++ id(SolrType.string, true, true, false, "primary key of document, a combination of <source-url-hash><target-url-hash><four-digit-hex-counter> (28 characters)"),+ collection_sxt(SolrType.string, true, true, true, "tags that are attached to crawls/index generation to separate the search result into user-defined subsets"),++ source_id_s(SolrType.string, true, true, false, "primary key of document, the URL hash (source)"),+ source_url_s(SolrType.string, true, true, false, "the url of the document (source)"),+ source_file_ext_s(SolrType.string, true, true, false, "the file name extension (source)"),+ source_tag_s(SolrType.string, true, true, false, "normalized (absolute URLs), as <a> - tag with anchor text and nofollow (source)"),+ source_chars_i(SolrType.num_integer, true, true, false, "number of all characters in the url (source)"),+ source_protocol_s(SolrType.string, true, true, false, "the protocol of the url (source)"),+ source_path_s(SolrType.string, true, true, true, "path of the url (source)"),+ source_path_folders_count_i(SolrType.num_integer, true, true, false, "count of all path elements in the url (source)"),+ source_path_folders_sxt(SolrType.string, true, true, true, "all path elements in the url (source)"),+ source_parameter_count_i(SolrType.num_integer, true, true, false, "number of key-value pairs in search part of the url (source)"),+ source_parameter_key_sxt(SolrType.string, true, true, true, "the keys from key-value pairs in the search part of the url (source)"),+ source_parameter_value_sxt(SolrType.string, true, true, true, "the values from key-value pairs in the search part of the url (source)"),+ source_clickdepth_i(SolrType.num_integer, true, true, false, "depth of web page according to number of clicks from the 'main' page, which is the page that appears if only the host is entered as url (source)"),++ source_host_s(SolrType.string, true, true, false, "host of the url"),+ source_host_dnc_s(SolrType.string, true, true, false, "the Domain Class Name, either the TLD or a combination of ccSLD+TLD if a ccSLD is used (source)"),+ source_host_organization_s(SolrType.string, true, true, false, "either the second level domain or, if a ccSLD is used, the third level domain"),+ source_host_organizationdnc_s(SolrType.string, true, true, false, "the organization and dnc concatenated with '.' (source)"),+ source_host_subdomain_s(SolrType.string, true, true, false, "the remaining part of the host without organizationdnc (source)"),++ target_linktext_t(SolrType.text_general, true, true, false, "the text content of the a-tag (in source, but pointing to a target)"),+ target_linktext_charcount_i(SolrType.num_integer, true, true, false, "the length of the a-tag content text as number of characters (in source, but pointing to a target)"),+ target_linktext_wordcount_i(SolrType.num_integer, true, true, false, "the length of the a-tag content text as number of words (in source, but pointing to a target)"),+ target_alt_t(SolrType.text_general, true, true, false, "if the link is an image link, this contains the alt tag if the image is also liked as img link (in source, but pointing to a target)"),+ target_alt_charcount_i(SolrType.num_integer, true, true, false, "the length of the a-tag content text as number of characters (in source, but pointing to a target)"),+ target_alt_wordcount_i(SolrType.num_integer, true, true, false, "the length of the a-tag content text as number of words (in source, but pointing to a target)"),+ target_name_t(SolrType.text_general, true, true, false, "the name property of the a-tag (in source, but pointing to a target)"),+ target_rel_s(SolrType.string, true, true, false, "the rel property of the a-tag (in source, but pointing to a target)"),+ target_relflags_i(SolrType.num_integer, true, true, false, "the rel property of the a-tag, coded binary (in source, but pointing to a target)"),++ target_id_s(SolrType.string, true, true, false, "primary key of document, the URL hash (target)"),+ target_url_s(SolrType.string, true, true, false, "the url of the document (target)"),+ target_file_ext_s(SolrType.string, true, true, false, "the file name extension (target)"),+ target_tag_s(SolrType.string, true, true, false, "normalized (absolute URLs), as <a> - tag with anchor text and nofollow (target)"),+ target_chars_i(SolrType.num_integer, true, true, false, "number of all characters in the url (target)"),+ target_protocol_s(SolrType.string, true, true, false, "the protocol of the url (target)"),+ target_path_s(SolrType.string, true, true, true, "path of the url (target)"),+ target_path_folders_count_i(SolrType.num_integer, true, true, true, "count of all path elements in the url (target)"),+ target_path_folders_sxt(SolrType.string, true, true, true, "all path elements in the url (target)"),+ target_parameter_count_i(SolrType.num_integer, true, true, false, "number of key-value pairs in search part of the url (target)"),+ target_parameter_key_sxt(SolrType.string, true, true, true, "the keys from key-value pairs in the search part of the url (target)"),+ target_parameter_value_sxt(SolrType.string, true, true, true, "the values from key-value pairs in the search part of the url (target)"),+ target_clickdepth_i(SolrType.num_integer, true, true, false, "depth of web page according to number of clicks from the 'main' page, which is the page that appears if only the host is entered as url (target)"),++ target_host_s(SolrType.string, true, true, false, "host of the url (target)"),+ target_host_dnc_s(SolrType.string, true, true, false, "the Domain Class Name, either the TLD or a combination of ccSLD+TLD if a ccSLD is used (target)"),+ target_host_organization_s(SolrType.string, true, true, false, "either the second level domain or, if a ccSLD is used, the third level domain (target)"),+ target_host_organizationdnc_s(SolrType.string, true, true, false, "the organization and dnc concatenated with '.' (target)"),+ target_host_subdomain_s(SolrType.string, true, true, false, "the remaining part of the host without organizationdnc (target)");++ public final static String CORE_NAME = "webgraph";++ public final static String VOCABULARY_PREFIX = "vocabulary_";+ public final static String VOCABULARY_SUFFIX = "_sxt";++ private String solrFieldName = null; // solr field name in custom solr schema+ private final SolrType type;+ private final boolean indexed, stored;+ private boolean multiValued, omitNorms;+ private String comment;++ private WebgraphSchema(final SolrType type, final boolean indexed, final boolean stored, final boolean multiValued, final String comment) {+ this.type = type;+ this.indexed = indexed;+ this.stored = stored;+ this.multiValued = multiValued;+ this.omitNorms = false;+ this.comment = comment;+ assert type.appropriateName(this.name(), this.multiValued) : "bad configuration: " + this.name();+ }++ private WebgraphSchema(final SolrType type, final boolean indexed, final boolean stored, final boolean multiValued, final boolean omitNorms, final String comment) {+ this(type, indexed, stored, multiValued, comment);+ this.omitNorms = omitNorms;+ assert type.appropriateName(this.name(), this.multiValued) : "bad configuration: " + this.name();+ }++ /**+ * Returns the YaCy default or (if available) custom field name for Solr+ * @return SolrFieldname String+ */+ @Override+ public final String getSolrFieldName() {+ return (this.solrFieldName == null ? this.name() : this.solrFieldName);+ }++ /**+ * Set a custom Solr field name (and converts it to lower case)+ * @param theValue = the field name+ */+ public final void setSolrFieldName(String theValue) {+ // make sure no empty string is assigned+ if ( (theValue != null) && (!theValue.isEmpty()) ) {+ this.solrFieldName = theValue.toLowerCase();+ } else {+ this.solrFieldName = null;+ }+ }++ @Override+ public final SolrType getType() {+ return this.type;+ }++ @Override+ public final boolean isIndexed() {+ return this.indexed;+ }++ @Override+ public final boolean isStored() {+ return this.stored;+ }++ @Override+ public final boolean isMultiValued() {+ return this.multiValued;+ }++ @Override+ public final boolean isOmitNorms() {+ return this.omitNorms;+ }++ @Override+ public final String getComment() {+ return this.comment;+ }++ public final void add(final SolrInputDocument doc, final String value) {+ assert !this.isMultiValued();+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final Date value) {+ assert !this.isMultiValued();+ assert this.type == SolrType.date;+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final int value) {+ assert !this.isMultiValued();+ assert this.type == SolrType.num_integer;+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final long value) {+ assert !this.isMultiValued();+ assert this.type == SolrType.num_long;+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final String[] value) {+ assert this.isMultiValued();+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final Integer[] value) {+ assert this.isMultiValued();+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final List<?> value) {+ assert this.isMultiValued();+ if (value == null || value.size() == 0) {+ if (this.type == SolrType.num_integer) {+ doc.setField(this.getSolrFieldName(), new Integer[0]);+ } else if (this.type == SolrType.string) {+ doc.setField(this.getSolrFieldName(), new String[0]);+ } else {+ assert false;+ doc.setField(this.getSolrFieldName(), new Object[0]);+ }+ return;+ }+ if (this.type == SolrType.num_integer) {+ assert (value.iterator().next() instanceof Integer);+ doc.setField(this.getSolrFieldName(), value.toArray(new Integer[value.size()]));+ } else if (this.type == SolrType.string || this.type == SolrType.text_general) {+ assert (value.iterator().next() instanceof String);+ doc.setField(this.getSolrFieldName(), value.toArray(new String[value.size()]));+ } else {+ assert false : "ADD: type is " + this.type.name();+ doc.setField(this.getSolrFieldName(), value.toArray(new Object[value.size()]));+ }+ }++ public final void add(final SolrInputDocument doc, final float value) {+ assert !this.isMultiValued();+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final double value) {+ assert !this.isMultiValued();+ doc.setField(this.getSolrFieldName(), value);+ }++ public final void add(final SolrInputDocument doc, final boolean value) {+ assert !this.isMultiValued();+ doc.setField(this.getSolrFieldName(), value);+ }++}+diff --git a/source/net/yacy/server/serverObjects.java b/source/net/yacy/server/serverObjects.javaindex 0b2001cff..1bdd545ab 100644--- a/source/net/yacy/server/serverObjects.java+++ b/source/net/yacy/server/serverObjects.java@@ -61,12 +61,12 @@ import java.util.regex.Pattern;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;-import net.yacy.cora.federate.solr.YaCySchema;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.protocol.RequestHeader.FileType;import net.yacy.document.parser.html.CharacterCoding;import net.yacy.kelondro.util.Formatter;import net.yacy.search.Switchboard;+import net.yacy.search.schema.CollectionSchema;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.MultiMapSolrParams;@@ -513,9 +513,9 @@ public class serverObjects implements Serializable, Cloneable {return param.toString();}- public SolrParams toSolrParams(YaCySchema[] facets) {+ public SolrParams toSolrParams(CollectionSchema[] facets) {// check if all required post fields are there- if (!this.containsKey(CommonParams.DF)) this.put(CommonParams.DF, YaCySchema.text_t.getSolrFieldName()); // set default field to the text field+ if (!this.containsKey(CommonParams.DF)) this.put(CommonParams.DF, CollectionSchema.text_t.getSolrFieldName()); // set default field to the text fieldif (!this.containsKey(CommonParams.START)) this.put(CommonParams.START, "0"); // set default start itemif (!this.containsKey(CommonParams.ROWS)) this.put(CommonParams.ROWS, "10"); // set default number of search results