Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added deleteByQuery to solr connectors
Michael Peter Christend39463a85ccc
diff --git a/.classpath b/.classpathindex bdf89be5c..bef2c2b61 100644--- a/.classpath+++ b/.classpath@@ -60,8 +60,8 @@<classpathentry kind="lib" path="lib/fontbox-1.7.0.jar"/><classpathentry kind="lib" path="lib/pdfbox-1.7.0.jar"/><classpathentry kind="lib" path="lib/jempbox-1.7.0.jar"/>- <classpathentry kind="lib" path="lib/apache-solr-core-3.6.1.jar"/>- <classpathentry kind="lib" path="lib/apache-solr-solrj-3.6.1.jar"/>+ <classpathentry kind="lib" path="lib/apache-solr-core-3.6.1.jar" sourcepath="/Volumes/Raptor/Data/sourcecode/solr-3.6.1/core/src/java"/>+ <classpathentry kind="lib" path="lib/apache-solr-solrj-3.6.1.jar" sourcepath="/Volumes/Raptor/Data/sourcecode/solr-3.6.1/core/src/java"/><classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/><classpathentry kind="lib" path="lib/icu4j-core.jar"/><classpathentry kind="lib" path="lib/htmllexer.jar"/>diff --git a/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java b/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.javaindex a7de26fcd..7ba32d6ba 100644--- a/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java+++ b/source/net/yacy/cora/services/federated/solr/AbstractSolrConnector.java@@ -141,6 +141,20 @@ public class AbstractSolrConnector implements SolrConnector {}}+ /**+ * delete entries from solr according the given solr query string+ * @param id the url hash of the entry+ * @throws IOException+ */+ @Override+ public void deleteByQuery(final String querystring) throws IOException {+ try {+ this.server.deleteByQuery(querystring, this.commitWithinMs);+ } catch (final Throwable e) {+ throw new IOException(e);+ }+ }+@Overridepublic boolean exists(final String id) throws IOException {try {diff --git a/source/net/yacy/cora/services/federated/solr/MirrorSolrConnector.java b/source/net/yacy/cora/services/federated/solr/MirrorSolrConnector.javaindex bf306a193..4830d3bdd 100644--- a/source/net/yacy/cora/services/federated/solr/MirrorSolrConnector.java+++ b/source/net/yacy/cora/services/federated/solr/MirrorSolrConnector.java@@ -170,6 +170,15 @@ public class MirrorSolrConnector implements SolrConnector {if (this.solr1 != null) this.solr1.delete(ids);}+ @Override+ public void deleteByQuery(final String querystring) throws IOException {+ if (this.solr0 != null) this.solr0.deleteByQuery(querystring);+ if (this.solr1 != null) this.solr1.deleteByQuery(querystring);+ this.hitCache.clear();+ this.missCache.clear();+ this.documentCache.clear();+ }+/*** check if a given id exists in solr* @param iddiff --git a/source/net/yacy/cora/services/federated/solr/MultipleSolrConnector.java b/source/net/yacy/cora/services/federated/solr/MultipleSolrConnector.javaindex 983a89cc8..144a1287b 100644--- a/source/net/yacy/cora/services/federated/solr/MultipleSolrConnector.java+++ b/source/net/yacy/cora/services/federated/solr/MultipleSolrConnector.java@@ -128,6 +128,11 @@ public class MultipleSolrConnector implements SolrConnector {this.solr.delete(ids);}+ @Override+ public void deleteByQuery(final String querystring) throws IOException {+ this.solr.deleteByQuery(querystring);+ }+@Overridepublic boolean exists(String id) throws IOException {return this.solr.exists(id);diff --git a/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java b/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.javaindex 0fd577676..ec7f48e3c 100644--- a/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java+++ b/source/net/yacy/cora/services/federated/solr/RetrySolrConnector.java@@ -103,6 +103,21 @@ public class RetrySolrConnector implements SolrConnector {if (ee != null) throw (ee instanceof IOException) ? (IOException) ee : new IOException(ee.getMessage());}+ @Override+ public void deleteByQuery(final String querystring) throws IOException {+ final long t = System.currentTimeMillis() + this.retryMaxTime;+ Throwable ee = null;+ while (System.currentTimeMillis() < t) try {+ this.solrConnector.deleteByQuery(querystring);+ return;+ } catch (final Throwable e) {+ ee = e;+ try {Thread.sleep(10);} catch (final InterruptedException e1) {}+ continue;+ }+ if (ee != null) throw (ee instanceof IOException) ? (IOException) ee : new IOException(ee.getMessage());+ }+@Overridepublic boolean exists(final String id) throws IOException {final long t = System.currentTimeMillis() + this.retryMaxTime;diff --git a/source/net/yacy/cora/services/federated/solr/ShardSolrConnector.java b/source/net/yacy/cora/services/federated/solr/ShardSolrConnector.javaindex 52eaa6309..eddc6fff5 100644--- a/source/net/yacy/cora/services/federated/solr/ShardSolrConnector.java+++ b/source/net/yacy/cora/services/federated/solr/ShardSolrConnector.java@@ -104,6 +104,11 @@ public class ShardSolrConnector implements SolrConnector {for (final SolrConnector connector: this.connectors) connector.delete(ids);}+ @Override+ public void deleteByQuery(final String querystring) throws IOException {+ for (final SolrConnector connector: this.connectors) connector.deleteByQuery(querystring);+ }+/*** check if a given id exists in solr* @param iddiff --git a/source/net/yacy/cora/services/federated/solr/SolrConnector.java b/source/net/yacy/cora/services/federated/solr/SolrConnector.javaindex 41434c4a0..cf79f0796 100644--- a/source/net/yacy/cora/services/federated/solr/SolrConnector.java+++ b/source/net/yacy/cora/services/federated/solr/SolrConnector.java@@ -72,6 +72,13 @@ public interface SolrConnector {*/public void delete(final List<String> ids) throws IOException;+ /**+ * delete entries from solr according the given solr query string+ * @param id the url hash of the entry+ * @throws IOException+ */+ public void deleteByQuery(final String querystring) throws IOException;+/*** check if a given id exists in solr* @param id