fixes for solr 8.8.1 migration

- replace new guava 30 with older 25 because that is the correct
dependency for solr 8.8.1. The newer one did actually not work!
- index will be crated in a DATA/INDEX/freeworld/SEGMENTS/solr_8_8_1
subfolder. The older solr_6_6 index is not touched but also not
migrated. The index starts with fresh (empty) content.
- Older indexes must be migrated by hand (export/import) so far until a
better solution is found.
- Large schema adoptions for lucene 8.8.1
pull/404/head
Michael Peter Christen 4 years ago
parent 3befaaf4f1
commit 8b4394a6c5

@ -18,7 +18,6 @@
<classpathentry kind="lib" path="lib/common-io-3.3.2.jar"/> <classpathentry kind="lib" path="lib/common-io-3.3.2.jar"/>
<classpathentry kind="lib" path="lib/common-lang-3.3.2.jar"/> <classpathentry kind="lib" path="lib/common-lang-3.3.2.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.14.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.14.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.2.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.20.jar"/> <classpathentry kind="lib" path="lib/commons-compress-1.20.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.4.jar"/> <classpathentry kind="lib" path="lib/commons-fileupload-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.7.jar"/> <classpathentry kind="lib" path="lib/commons-io-2.7.jar"/>
@ -27,7 +26,6 @@
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/> <classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="lib/commons-math3-3.4.1.jar"/> <classpathentry kind="lib" path="lib/commons-math3-3.4.1.jar"/>
<classpathentry kind="lib" path="lib/fontbox-2.0.15.jar"/> <classpathentry kind="lib" path="lib/fontbox-2.0.15.jar"/>
<classpathentry kind="lib" path="lib/guava-30.1-jre.jar"/>
<classpathentry kind="lib" path="lib/http2-client-9.4.34.v20201102.jar"/> <classpathentry kind="lib" path="lib/http2-client-9.4.34.v20201102.jar"/>
<classpathentry kind="lib" path="lib/http2-common-9.4.34.v20201102.jar"/> <classpathentry kind="lib" path="lib/http2-common-9.4.34.v20201102.jar"/>
<classpathentry kind="lib" path="lib/http2-http-client-transport-9.4.34.v20201102.jar"/> <classpathentry kind="lib" path="lib/http2-http-client-transport-9.4.34.v20201102.jar"/>
@ -109,6 +107,8 @@
<classpathentry kind="lib" path="libt/hamcrest-2.2.jar"/> <classpathentry kind="lib" path="libt/hamcrest-2.2.jar"/>
<classpathentry kind="lib" path="libt/hamcrest-core-2.2.jar"/> <classpathentry kind="lib" path="libt/hamcrest-core-2.2.jar"/>
<classpathentry kind="lib" path="libt/hamcrest-library-2.2.jar"/> <classpathentry kind="lib" path="libt/hamcrest-library-2.2.jar"/>
<classpathentry kind="lib" path="lib/commons-collections4-4.4.jar"/>
<classpathentry kind="lib" path="lib/guava-25.1-jre.jar"/>
<classpathentry kind="src" path="htroot/api/blacklists"/> <classpathentry kind="src" path="htroot/api/blacklists"/>
<classpathentry kind="src" path="htroot/api/bookmarks/posts"/> <classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
<classpathentry kind="src" path="htroot/api/bookmarks/tags"/> <classpathentry kind="src" path="htroot/api/bookmarks/tags"/>

@ -184,7 +184,7 @@
<pathelement location="${lib}/common-io-3.3.2.jar" /> <pathelement location="${lib}/common-io-3.3.2.jar" />
<pathelement location="${lib}/common-lang-3.3.2.jar" /> <pathelement location="${lib}/common-lang-3.3.2.jar" />
<pathelement location="${lib}/commons-codec-1.14.jar" /> <pathelement location="${lib}/commons-codec-1.14.jar" />
<pathelement location="${lib}/commons-collections-3.2.2.jar" /> <pathelement location="${lib}/commons-collections4-4.4.jar" />
<pathelement location="${lib}/commons-compress-1.20.jar" /> <pathelement location="${lib}/commons-compress-1.20.jar" />
<pathelement location="${lib}/commons-fileupload-1.4.jar" /> <pathelement location="${lib}/commons-fileupload-1.4.jar" />
<pathelement location="${lib}/commons-io-2.7.jar" /> <pathelement location="${lib}/commons-io-2.7.jar" />
@ -193,7 +193,7 @@
<pathelement location="${lib}/commons-logging-1.2.jar" /> <pathelement location="${lib}/commons-logging-1.2.jar" />
<pathelement location="${lib}/commons-math3-3.4.1.jar" /> <pathelement location="${lib}/commons-math3-3.4.1.jar" />
<pathelement location="${lib}/fontbox-2.0.15.jar" /> <pathelement location="${lib}/fontbox-2.0.15.jar" />
<pathelement location="${lib}/guava-30.1-jre.jar" /> <pathelement location="${lib}/guava-25.1-jre.jar" />
<pathelement location="${lib}/http2-client-9.4.34.v20201102.jar" /> <pathelement location="${lib}/http2-client-9.4.34.v20201102.jar" />
<pathelement location="${lib}/http2-common-9.4.34.v20201102.jar" /> <pathelement location="${lib}/http2-common-9.4.34.v20201102.jar" />
<pathelement location="${lib}/http2-http-client-transport-9.4.34.v20201102.jar" /> <pathelement location="${lib}/http2-http-client-transport-9.4.34.v20201102.jar" />

@ -2,18 +2,18 @@
<schema name="YaCy2Solr" version="1.4"> <schema name="YaCy2Solr" version="1.4">
<types> <types>
<fieldType name="string" class="solr.StrField" omitNorms="true" sortMissingLast="true" docValues="true" /> <fieldType name="string" class="solr.StrField" omitNorms="true" sortMissingLast="true" docValues="true" />
<fieldType name="boolean" class="solr.BoolField" omitNorms="true" sortMissingLast="true" /> <fieldType name="boolean" class="solr.BoolField" omitNorms="true" sortMissingLast="true" />
<fieldType name="int" class="solr.TrieIntField" omitNorms="true" precisionStep="0" positionIncrementGap="0" docValues="true" /> <fieldType name="int" class="solr.IntPointField" docValues="true" omitNorms="true" />
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0" docValues="true" /> <fieldType name="tint" class="solr.IntPointField" docValues="true" />
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0" docValues="true" /> <fieldType name="long" class="solr.LongPointField" docValues="true" />
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0" docValues="true" /> <fieldType name="tlong" class="solr.LongPointField" docValues="true" />
<fieldType name="double" class="solr.TrieDoubleField" omitNorms="true" precisionStep="0" positionIncrementGap="0" docValues="true" /> <fieldType name="double" class="solr.DoublePointField" docValues="true" omitNorms="true" />
<fieldType name="tdouble" class="solr.TrieDoubleField" omitNorms="true" precisionStep="8" positionIncrementGap="0" docValues="true" /> <fieldType name="tdouble" class="solr.DoublePointField" docValues="true" omitNorms="true" />
<fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0" docValues="true" /> <fieldType name="date" class="solr.DatePointField" docValues="true" omitNorms="true" />
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0" docValues="true" /> <fieldType name="float" class="solr.FloatPointField" docValues="true" />
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0" docValues="true" /> <fieldType name="tfloat" class="solr.FloatPointField" docValues="true" />
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/> <fieldType name="location" class="solr.LatLonPointSpatialField" />
<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true"> <fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer type="index"> <analyzer type="index">
@ -22,7 +22,7 @@
</analyzer> </analyzer>
<analyzer type="query"> <analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.LowerCaseFilterFactory"/>
</analyzer> </analyzer>
</fieldType> </fieldType>
@ -36,7 +36,7 @@
<analyzer type="query"> <analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/> <tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.LowerCaseFilterFactory"/>
</analyzer> </analyzer>
</fieldType> </fieldType>
@ -44,9 +44,9 @@
<fieldType name="text_en_splitting_tight" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true"> <fieldType name="text_en_splitting_tight" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer> <analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/> <filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/> <filter class="solr.WordDelimiterGraphFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>
<filter class="solr.LowerCaseFilterFactory"/><filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> <filter class="solr.LowerCaseFilterFactory"/><filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.EnglishMinimalStemFilterFactory"/> <filter class="solr.EnglishMinimalStemFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>

@ -35,7 +35,7 @@
that you fully re-index after changing this setting as it can that you fully re-index after changing this setting as it can
affect both how text is indexed and queried. affect both how text is indexed and queried.
--> -->
<luceneMatchVersion>6.6.0</luceneMatchVersion> <luceneMatchVersion>8.8.1</luceneMatchVersion>
<!-- <lib/> directives can be used to instruct Solr to load any Jars <!-- <lib/> directives can be used to instruct Solr to load any Jars
identified and use them to resolve any "plugins" specified in identified and use them to resolve any "plugins" specified in

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -121,7 +121,7 @@ public class EmbeddedInstance implements SolrInstance {
if (!core_properties.exists()) { if (!core_properties.exists()) {
// create the file // create the file
try ( try (
/* Automatically closed by this try-with-resources statement */ /* Automatically closed by this try-with-resources statement */
FileOutputStream fos = new FileOutputStream(core_properties); FileOutputStream fos = new FileOutputStream(core_properties);
) { ) {
fos.write(ASCII.getBytes("name=" + coreName + "\n")); fos.write(ASCII.getBytes("name=" + coreName + "\n"));

@ -90,8 +90,8 @@ import org.apache.solr.schema.IndexSchema;
public final class Fulltext { public final class Fulltext {
private static final String SOLR_PATH = "solr_6_6"; // the number should be identical to the number in the property luceneMatchVersion in solrconfig.xml private static final String SOLR_PATH = "solr_8_8_1"; // the number should be identical to the number in the property luceneMatchVersion in solrconfig.xml
private static final String SOLR_OLD_PATH[] = new String[]{"solr_36", "solr_40", "solr_44", "solr_45", "solr_46", "solr_47", "solr_4_9", "solr_4_10", "solr_5_2", "solr_5_5"}; private static final String SOLR_OLD_PATH[] = new String[]{"solr_36", "solr_40", "solr_44", "solr_45", "solr_46", "solr_47", "solr_4_9", "solr_4_10", "solr_5_2", "solr_5_5", "solr_6_6"};
// class objects // class objects
private final File segmentPath; private final File segmentPath;
@ -140,24 +140,28 @@ public final class Fulltext {
public void connectLocalSolr() throws IOException { public void connectLocalSolr() throws IOException {
File solrLocation = new File(this.segmentPath, SOLR_PATH); File solrLocation = new File(this.segmentPath, SOLR_PATH);
// migrate old solr to new // migrate old solr to new
/*
for (String oldVersion: SOLR_OLD_PATH) { for (String oldVersion: SOLR_OLD_PATH) {
File oldLocation = new File(this.segmentPath, oldVersion); File oldLocation = new File(this.segmentPath, oldVersion);
if (oldLocation.exists()) { if (oldLocation.exists()) {
if(!oldLocation.renameTo(solrLocation)) { if(!oldLocation.renameTo(solrLocation)) {
ConcurrentLog.severe("Fulltext", "Failed renaming old Solr location (" ConcurrentLog.severe("Fulltext", "Failed renaming old Solr location ("
+ oldLocation.getAbsolutePath() + ") to new location : " + solrLocation.getAbsolutePath()); + oldLocation.getAbsolutePath() + ") to new location : " + solrLocation.getAbsolutePath());
} }
} }
} }
*/
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}); 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});
SolrConfig config = localCollectionInstance.getDefaultCore().getSolrConfig(); SolrConfig config = localCollectionInstance.getDefaultCore().getSolrConfig();
String versionValue = config.getVal(IndexSchema.LUCENE_MATCH_VERSION_PARAM, true); String versionValue = config.getVal(IndexSchema.LUCENE_MATCH_VERSION_PARAM, true);
Version luceneVersion = SolrConfig.parseLuceneVersionString(versionValue); Version luceneVersion = SolrConfig.parseLuceneVersionString(versionValue);
String lvn = luceneVersion.major + "_" + luceneVersion.minor; String lvn = luceneVersion.major + "_" + luceneVersion.minor + "_" + luceneVersion.bugfix;
ConcurrentLog.info("Fulltext", "using lucene version " + lvn);
assert SOLR_PATH.endsWith(lvn) : "luceneVersion = " + lvn + ", solrPath = " + SOLR_PATH + ", check defaults/solr/solrconfig.xml"; assert SOLR_PATH.endsWith(lvn) : "luceneVersion = " + lvn + ", solrPath = " + SOLR_PATH + ", check defaults/solr/solrconfig.xml";
ConcurrentLog.info("Fulltext", "using lucene version " + lvn);
ConcurrentLog.info("Fulltext", "connected solr in " + solrLocation.toString() + ", lucene version " + lvn); ConcurrentLog.info("Fulltext", "connected solr in " + solrLocation.toString() + ", lucene version " + lvn);
this.solrInstances.connectEmbedded(localCollectionInstance); this.solrInstances.connectEmbedded(localCollectionInstance);
} }
@ -194,12 +198,12 @@ public final class Fulltext {
public RemoteSolrConnector getDefaultRemoteSolrConnector() { public RemoteSolrConnector getDefaultRemoteSolrConnector() {
try { try {
boolean useBinaryResponseWriter = SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT; boolean useBinaryResponseWriter = SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT;
if (Switchboard.getSwitchboard() != null) { if (Switchboard.getSwitchboard() != null) {
useBinaryResponseWriter = Switchboard.getSwitchboard().getConfigBool( useBinaryResponseWriter = Switchboard.getSwitchboard().getConfigBool(
SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED, SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED,
SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT); SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT);
} }
return this.solrInstances.getDefaultRemoteConnector(useBinaryResponseWriter); return this.solrInstances.getDefaultRemoteConnector(useBinaryResponseWriter);
} catch (IOException e) { } catch (IOException e) {
return null; return null;
@ -207,35 +211,35 @@ public final class Fulltext {
} }
public EmbeddedInstance getEmbeddedInstance() { public EmbeddedInstance getEmbeddedInstance() {
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
if (this.solrInstances.isConnectedEmbedded()) { if (this.solrInstances.isConnectedEmbedded()) {
return this.solrInstances.getEmbedded(); return this.solrInstances.getEmbedded();
} }
return null; return null;
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
public SolrConnector getDefaultConnector() { public SolrConnector getDefaultConnector() {
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
return this.solrInstances.getDefaultMirrorConnector(); return this.solrInstances.getDefaultMirrorConnector();
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
public SolrConnector getWebgraphConnector() { public SolrConnector getWebgraphConnector() {
if (!this.writeWebgraph) { if (!this.writeWebgraph) {
return null; return null;
} }
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
return this.solrInstances.getGenericMirrorConnector(WebgraphSchema.CORE_NAME); return this.solrInstances.getGenericMirrorConnector(WebgraphSchema.CORE_NAME);
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
@ -249,9 +253,9 @@ public final class Fulltext {
public void clearLocalSolr() throws IOException { public void clearLocalSolr() throws IOException {
if (this.exportthread != null) { if (this.exportthread != null) {
this.exportthread.interrupt(); this.exportthread.interrupt();
} }
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
EmbeddedInstance instance = this.solrInstances.getEmbedded(); EmbeddedInstance instance = this.solrInstances.getEmbedded();
if (instance != null) { if (instance != null) {
@ -262,12 +266,12 @@ public final class Fulltext {
} }
this.solrInstances.clearCaches(); this.solrInstances.clearCaches();
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
public void clearRemoteSolr() throws IOException { public void clearRemoteSolr() throws IOException {
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
ShardInstance instance = this.solrInstances.getRemote(); ShardInstance instance = this.solrInstances.getRemote();
if (instance != null) { if (instance != null) {
@ -277,7 +281,7 @@ public final class Fulltext {
} }
this.solrInstances.clearCaches(); this.solrInstances.clearCaches();
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
@ -309,7 +313,7 @@ public final class Fulltext {
try { try {
this.solrInstances.close(); this.solrInstances.close();
} catch (Throwable e) { } catch (Throwable e) {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
} }
} }
@ -354,7 +358,7 @@ public final class Fulltext {
try { try {
SolrDocument doc = this.getDefaultConnector().getDocumentById(u); SolrDocument doc = this.getDefaultConnector().getDocumentById(u);
if (doc != null) { if (doc != null) {
return new URIMetadataNode(doc, wre, score); return new URIMetadataNode(doc, wre, score);
} }
} catch (final IOException e) { } catch (final IOException e) {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
@ -493,7 +497,6 @@ public final class Fulltext {
} }
} }
/** /**
* remove a full subpath from the index * remove a full subpath from the index
* @param basepath the left path of the url; at least until the end of the host * @param basepath the left path of the url; at least until the end of the host
@ -533,7 +536,7 @@ public final class Fulltext {
this.getDefaultConnector().deleteByIds(deleteIDs); this.getDefaultConnector().deleteByIds(deleteIDs);
if (this.writeWebgraph) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s if (this.writeWebgraph) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s
for (String id : deleteIDs) { for (String id : deleteIDs) {
/* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */ /* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */
this.getWebgraphConnector().deleteByQuery(WebgraphSchema.source_id_s.name() + ":\"" + id + "\""); this.getWebgraphConnector().deleteByQuery(WebgraphSchema.source_id_s.name() + ":\"" + id + "\"");
} }
} }
@ -554,7 +557,7 @@ public final class Fulltext {
String id = ASCII.String(urlHash); String id = ASCII.String(urlHash);
this.getDefaultConnector().deleteById(id); this.getDefaultConnector().deleteById(id);
if (this.writeWebgraph) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s if (this.writeWebgraph) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s
/* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */ /* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */
this.getWebgraphConnector().deleteByQuery(WebgraphSchema.source_id_s + ":\"" + id + "\""); this.getWebgraphConnector().deleteByQuery(WebgraphSchema.source_id_s + ":\"" + id + "\"");
} }
} catch (final Throwable e) { } catch (final Throwable e) {
@ -613,11 +616,11 @@ public final class Fulltext {
public File dumpEmbeddedSolr() throws SolrException { public File dumpEmbeddedSolr() throws SolrException {
final EmbeddedInstance esc = this.solrInstances.getEmbedded(); final EmbeddedInstance esc = this.solrInstances.getEmbedded();
if(esc == null) { if(esc == null) {
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "No embedded Solr available."); throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "No embedded Solr available.");
} }
final File storagePath = esc.getContainerPath(); final File storagePath = esc.getContainerPath();
final File zipOut = new File(this.archivePath, storagePath.getName() + "_" + GenericFormatter.SHORT_DAY_FORMATTER.format() + ".zip"); final File zipOut = new File(this.archivePath, storagePath.getName() + "_" + GenericFormatter.SHORT_DAY_FORMATTER.format() + ".zip");
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
this.disconnectLocalSolr(); this.disconnectLocalSolr();
try { try {
@ -632,7 +635,7 @@ public final class Fulltext {
} }
} }
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
return zipOut; return zipOut;
} }
@ -645,10 +648,10 @@ public final class Fulltext {
public void restoreEmbeddedSolr(final File solrDumpZipFile) { public void restoreEmbeddedSolr(final File solrDumpZipFile) {
final EmbeddedInstance esc = this.solrInstances.getEmbedded(); final EmbeddedInstance esc = this.solrInstances.getEmbedded();
if(esc == null) { if(esc == null) {
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "No embedded Solr available."); throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "No embedded Solr available.");
} }
final File storagePath = esc.getContainerPath(); final File storagePath = esc.getContainerPath();
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
// this.disconnectLocalSolr(); // moved to (InstanceMirror) sorlInstances.close() // this.disconnectLocalSolr(); // moved to (InstanceMirror) sorlInstances.close()
this.solrInstances.close(); this.solrInstances.close();
@ -665,7 +668,7 @@ public final class Fulltext {
} }
} }
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
@ -684,7 +687,7 @@ public final class Fulltext {
* Please check before that the local embedded Solr is enabled and no external remote Solr is attached. * Please check before that the local embedded Solr is enabled and no external remote Solr is attached.
*/ */
public void rebootEmbeddedLocalSolr() { public void rebootEmbeddedLocalSolr() {
this.solrInstancesLock.lock(); this.solrInstancesLock.lock();
try { try {
this.disconnectLocalSolr(); this.disconnectLocalSolr();
// this.solrInstances.close(); // moved to (InstanceMirror) sorlInstances.close() // this.solrInstances.close(); // moved to (InstanceMirror) sorlInstances.close()
@ -695,7 +698,7 @@ public final class Fulltext {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
} }
} finally { } finally {
this.solrInstancesLock.unlock(); this.solrInstancesLock.unlock();
} }
} }
@ -732,47 +735,46 @@ public final class Fulltext {
final long doccount; final long doccount;
final Date firstdate, lastdate; final Date firstdate, lastdate;
if (firstdoclist.size() == 0 || lastdoclist.size() == 0) { if (firstdoclist.size() == 0 || lastdoclist.size() == 0) {
/* Now check again the number of documents without sorting, for compatibility with old fields indexed without DocValues fields (prior to YaCy 1.90) /* Now check again the number of documents without sorting, for compatibility with old fields indexed without DocValues fields (prior to YaCy 1.90)
* When the local Solr index contains such old documents, requests with sort query return nothing and trace in logs * When the local Solr index contains such old documents, requests with sort query return nothing and trace in logs
* "java.lang.IllegalStateException: unexpected docvalues type NONE for field..." */ * "java.lang.IllegalStateException: unexpected docvalues type NONE for field..." */
doccount = this.getDefaultConnector().getCountByQuery(query); doccount = this.getDefaultConnector().getCountByQuery(query);
if(doccount == 0) { if(doccount == 0) {
/* Finally no document to export was found */ /* Finally no document to export was found */
throw new IOException("number of exported documents == 0"); throw new IOException("number of exported documents == 0");
} }
/* we use default date values just to generate a proper dump file path */ /* we use default date values just to generate a proper dump file path */
firstdate = new Date(0); firstdate = new Date(0);
lastdate = new Date(0); lastdate = new Date(0);
} else { } else {
doccount = firstdoclist.getNumFound(); doccount = firstdoclist.getNumFound();
// create the export name // create the export name
SolrDocument firstdoc = firstdoclist.get(0); SolrDocument firstdoc = firstdoclist.get(0);
SolrDocument lastdoc = lastdoclist.get(0); SolrDocument lastdoc = lastdoclist.get(0);
firstdateobject = firstdoc.getFieldValue(CollectionSchema.load_date_dt.getSolrFieldName()); firstdateobject = firstdoc.getFieldValue(CollectionSchema.load_date_dt.getSolrFieldName());
lastdateobject = lastdoc.getFieldValue(CollectionSchema.load_date_dt.getSolrFieldName()); lastdateobject = lastdoc.getFieldValue(CollectionSchema.load_date_dt.getSolrFieldName());
/* When firstdate or lastdate is null, we use a default one just to generate a proper dump file path /* When firstdate or lastdate is null, we use a default one just to generate a proper dump file path
* This should not happen because load_date_dt field is mandatory in the main Solr schema, * This should not happen because load_date_dt field is mandatory in the main Solr schema,
* but for some reason some documents might end up here with an empty load_date_dt field value */ * but for some reason some documents might end up here with an empty load_date_dt field value */
if(firstdateobject instanceof Date) { if(firstdateobject instanceof Date) {
firstdate = (Date) firstdateobject; firstdate = (Date) firstdateobject;
} else { } else {
ConcurrentLog.warn("Fulltext", "The required field " + CollectionSchema.load_date_dt.getSolrFieldName() + " is empty on document with id : " ConcurrentLog.warn("Fulltext", "The required field " + CollectionSchema.load_date_dt.getSolrFieldName() + " is empty on document with id : "
+ firstdoc.getFieldValue(CollectionSchema.id.getSolrFieldName())); + firstdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
firstdate = new Date(0); firstdate = new Date(0);
} }
if(lastdateobject instanceof Date) { if(lastdateobject instanceof Date) {
lastdate = (Date) lastdateobject; lastdate = (Date) lastdateobject;
} else { } else {
ConcurrentLog.warn("Fulltext", "The required field " + CollectionSchema.load_date_dt.getSolrFieldName() + " is empty on document with id : " ConcurrentLog.warn("Fulltext", "The required field " + CollectionSchema.load_date_dt.getSolrFieldName() + " is empty on document with id : "
+ lastdoc.getFieldValue(CollectionSchema.id.getSolrFieldName())); + lastdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
lastdate = new Date(0); lastdate = new Date(0);
} }
} }
String s = new File(path, yacy_dump_prefix + String s = new File(path, yacy_dump_prefix +
"f" + GenericFormatter.SHORT_MINUTE_FORMATTER.format(firstdate) + "_" + "f" + GenericFormatter.SHORT_MINUTE_FORMATTER.format(firstdate) + "_" +
"l" + GenericFormatter.SHORT_MINUTE_FORMATTER.format(lastdate) + "_" + "l" + GenericFormatter.SHORT_MINUTE_FORMATTER.format(lastdate) + "_" +
@ -799,8 +801,8 @@ public final class Fulltext {
} }
public static void main(String args[]) { public static void main(String args[]) {
Date firstdate = null; Date firstdate = null;
System.out.println(GenericFormatter.SHORT_MINUTE_FORMATTER.format(firstdate)); System.out.println(GenericFormatter.SHORT_MINUTE_FORMATTER.format(firstdate));
} }
public Export export() { public Export export() {
@ -816,7 +818,7 @@ public final class Fulltext {
private final boolean dom, text; private final boolean dom, text;
private Export(final File f, final String filter, final String query, final ExportFormat format, final boolean dom, final boolean text) { private Export(final File f, final String filter, final String query, final ExportFormat format, final boolean dom, final boolean text) {
super("Fulltext.Export"); super("Fulltext.Export");
// format: 0=text, 1=html, 2=rss/xml // format: 0=text, 1=html, 2=rss/xml
this.f = f; this.f = f;
this.pattern = filter == null ? null : Pattern.compile(filter); this.pattern = filter == null ? null : Pattern.compile(filter);
@ -831,20 +833,20 @@ public final class Fulltext {
@Override @Override
public void run() { public void run() {
try { try {
final File parentf = this.f.getParentFile(); final File parentf = this.f.getParentFile();
if (parentf != null) { if (parentf != null) {
parentf.mkdirs(); parentf.mkdirs();
} }
} catch(Exception e) { } catch(Exception e) {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
this.failure = e.getMessage(); this.failure = e.getMessage();
return; return;
} }
try (/* Resources automatically closed by this try-with-resources statement */ try (/* Resources automatically closed by this try-with-resources statement */
final OutputStream os = new FileOutputStream(this.format == ExportFormat.solr ? new File(this.f.getAbsolutePath() + ".gz") : this.f); final OutputStream os = new FileOutputStream(this.format == ExportFormat.solr ? new File(this.f.getAbsolutePath() + ".gz") : this.f);
final OutputStream wrappedStream = ((this.format == ExportFormat.solr)) ? new GZIPOutputStream(os, 65536){{def.setLevel(Deflater.BEST_COMPRESSION);}} : os; final OutputStream wrappedStream = ((this.format == ExportFormat.solr)) ? new GZIPOutputStream(os, 65536){{def.setLevel(Deflater.BEST_COMPRESSION);}} : os;
final PrintWriter pw = new PrintWriter(new BufferedOutputStream(wrappedStream)); final PrintWriter pw = new PrintWriter(new BufferedOutputStream(wrappedStream));
) { ) {
if (this.format == ExportFormat.html) { if (this.format == ExportFormat.html) {
@ -946,7 +948,7 @@ public final class Fulltext {
pw.println("</response>"); pw.println("</response>");
} }
} catch (final Exception e) { } catch (final Exception e) {
/* Catch but log any IO exception that can occur on copy, automatic closing or streams creation */ /* Catch but log any IO exception that can occur on copy, automatic closing or streams creation */
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
this.failure = e.getMessage(); this.failure = e.getMessage();
} }
@ -966,10 +968,10 @@ public final class Fulltext {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private String getStringFrom(final Object o) { private String getStringFrom(final Object o) {
if (o == null) return ""; if (o == null) return "";
if (o instanceof ArrayList) return ((ArrayList<String>) o).get(0); if (o instanceof ArrayList) return ((ArrayList<String>) o).get(0);
return (String) o; return (String) o;
} }
} }

Loading…
Cancel
Save