basic fragment choosing
[wolnelektury.git] / apps / search / management / commands / checkindex.py
1
2 from django.core.management.base import BaseCommand
3 from search import IndexChecker
4
5 class Command(BaseCommand):
6     help = 'Check Lucene search index'
7     args = ''
8
9     def handle(self, *args, **opts):
10         checker = IndexChecker()
11         status = checker.check()
12         if status.clean:
13             print "No problems found."
14         else:
15             if status.missingSegments:
16                 print "Unable to locate."
17             print "Number of bad segments: %d / %d (max segment name is %d)" % \
18                 (status.numBadSegments, status.numSegments, status.maxSegmentName)
19             print "Total lost documents (due to bad segments) %d" % status.totLoseDocCount
20             if not status.validCounter:
21                 print "Segment counter is not valid."
22