def handle(self, *args, **opts):
from catalogue.models import Book
import search
- idx = search.ReusableIndex()
- idx.open()
-
+ idx = search.Index()
+
if not opts['just_tags']:
if args:
books = []
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.close()
+ idx.index.commit()