Skip to content

Instantly share code, notes, and snippets.

@acdha
Last active August 29, 2015 14:08
Show Gist options
  • Save acdha/d81613fdce534f2dd3ad to your computer and use it in GitHub Desktop.
Save acdha/d81613fdce534f2dd3ad to your computer and use it in GitHub Desktop.
diff --git a/haystack/backends/solr_backend.py b/haystack/backends/solr_backend.py
index 777e35f..d1a05b0 100644
--- a/haystack/backends/solr_backend.py
+++ b/haystack/backends/solr_backend.py
@@ -103,8 +103,9 @@ class SolrSearchBackend(BaseSearchBackend):
self.conn.delete(q=" OR ".join(models_to_delete), commit=commit)
- # Run an optimize post-clear. http://wiki.apache.org/solr/FAQ#head-9aafb5d8dff5308e8ea4fcf4b71f19f029c4bb99
- self.conn.optimize()
+ if commit:
+ # Run an optimize post-clear. http://wiki.apache.org/solr/FAQ#head-9aafb5d8dff5308e8ea4fcf4b71f19f029c4bb99
+ self.conn.optimize()
except (IOError, SolrError) as e:
if not self.silently_fail:
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment