add committing, too
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 26 Oct 2012 11:04:45 +0000 (13:04 +0200)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 26 Oct 2012 11:04:45 +0000 (13:04 +0200)
apps/search/management/commands/reindex.py

index b1ec9c3..2d2000b 100755 (executable)
@@ -26,9 +26,14 @@ class Command(BaseCommand):
                         books += Book.objects.filter(slug=a).all()
             else:
                 books = Book.objects.all()
-                
-            for b in books:
-                print b.title
-                idx.index_book(b)
+
+            try:
+                for b in books:
+                    print b.title
+                    idx.index_book(b)
+                    idx.index.commit()
+            except:
+                idx.index.rollback()
         print 'Reindexing tags.'
         idx.index_tags()
+        idx.index.commit()