added deleteByQuery to solr connectors

pull/1/head
Michael Peter Christen 13 years ago
parent 0cab06c47c
commit d39463a85c

@ -60,8 +60,8 @@
<classpathentry kind="lib" path="lib/fontbox-1.7.0.jar"/> <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/pdfbox-1.7.0.jar"/>
<classpathentry kind="lib" path="lib/jempbox-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-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"/> <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="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/icu4j-core.jar"/> <classpathentry kind="lib" path="lib/icu4j-core.jar"/>
<classpathentry kind="lib" path="lib/htmllexer.jar"/> <classpathentry kind="lib" path="lib/htmllexer.jar"/>

@ -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);
}
}
@Override @Override
public boolean exists(final String id) throws IOException { public boolean exists(final String id) throws IOException {
try { try {

@ -170,6 +170,15 @@ public class MirrorSolrConnector implements SolrConnector {
if (this.solr1 != null) this.solr1.delete(ids); 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 * check if a given id exists in solr
* @param id * @param id

@ -128,6 +128,11 @@ public class MultipleSolrConnector implements SolrConnector {
this.solr.delete(ids); this.solr.delete(ids);
} }
@Override
public void deleteByQuery(final String querystring) throws IOException {
this.solr.deleteByQuery(querystring);
}
@Override @Override
public boolean exists(String id) throws IOException { public boolean exists(String id) throws IOException {
return this.solr.exists(id); return this.solr.exists(id);

@ -103,6 +103,21 @@ public class RetrySolrConnector implements SolrConnector {
if (ee != null) throw (ee instanceof IOException) ? (IOException) ee : new IOException(ee.getMessage()); 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());
}
@Override @Override
public boolean exists(final String id) throws IOException { public boolean exists(final String id) throws IOException {
final long t = System.currentTimeMillis() + this.retryMaxTime; final long t = System.currentTimeMillis() + this.retryMaxTime;

@ -104,6 +104,11 @@ public class ShardSolrConnector implements SolrConnector {
for (final SolrConnector connector: this.connectors) connector.delete(ids); 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 * check if a given id exists in solr
* @param id * @param id

@ -72,6 +72,13 @@ public interface SolrConnector {
*/ */
public void delete(final List<String> ids) throws IOException; 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 * check if a given id exists in solr
* @param id * @param id

Loading…
Cancel
Save