From: Marcin Koziej Date: Fri, 26 Oct 2012 11:04:45 +0000 (+0200) Subject: add committing, too X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/5f472f9710d81657a3aa6e3a170ce123e1ac3099?ds=inline;hp=--cc add committing, too --- 5f472f9710d81657a3aa6e3a170ce123e1ac3099 diff --git a/apps/search/management/commands/reindex.py b/apps/search/management/commands/reindex.py index b1ec9c3d7..2d2000bb9 100755 --- a/apps/search/management/commands/reindex.py +++ b/apps/search/management/commands/reindex.py @@ -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()