-class WLAnalyzer(PerFieldAnalyzerWrapper):
- def __init__(self):
- polish = PolishAnalyzer(Version.LUCENE_34)
- # polish_gap.setPositionIncrementGap(999)
-
- simple = SimpleAnalyzer(Version.LUCENE_34)
- # simple_gap.setPositionIncrementGap(999)
-
- keyword = KeywordAnalyzer(Version.LUCENE_34)
-
- # not sure if needed: there's NOT_ANALYZED meaning basically the same
-
- PerFieldAnalyzerWrapper.__init__(self, polish)
-
- self.addAnalyzer("tags", simple)
- self.addAnalyzer("technical_editors", simple)
- self.addAnalyzer("editors", simple)
- self.addAnalyzer("url", keyword)
- self.addAnalyzer("source_url", keyword)
- self.addAnalyzer("source_name", simple)
- self.addAnalyzer("publisher", simple)
- self.addAnalyzer("authors", simple)
- self.addAnalyzer("title", simple)
-
- self.addAnalyzer("is_book", keyword)
- # shouldn't the title have two forms? _pl and simple?
-
- self.addAnalyzer("themes", simple)
- self.addAnalyzer("themes_pl", polish)
-
- self.addAnalyzer("tag_name", simple)
- self.addAnalyzer("tag_name_pl", polish)
-
- self.addAnalyzer("translators", simple)
-
- self.addAnalyzer("KEYWORD", keyword)
- self.addAnalyzer("SIMPLE", simple)
- self.addAnalyzer("POLISH", polish)
-
-
-class IndexStore(object):
- """
- Provides access to search index.
-
- self.store - lucene index directory
- """
- def __init__(self):
- self.make_index_dir()
- self.store = SimpleFSDirectory(File(settings.SEARCH_INDEX))
-
- def make_index_dir(self):
- try:
- os.makedirs(settings.SEARCH_INDEX)
- except OSError as exc:
- if exc.errno == errno.EEXIST:
- pass
- else: raise
-
-
-class IndexChecker(IndexStore):
- def __init__(self):
- IndexStore.__init__(self)
-
- def check(self):
- checker = CheckIndex(self.store)
- status = checker.checkIndex()
- return status