X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1a013c54edacc9eaed551a648bf75284b794a820..f931a5a3c86e677475ae7f3fc0074b4940bee85c:/apps/search/index.py diff --git a/apps/search/index.py b/apps/search/index.py index 1a36993d6..b3e932285 100644 --- a/apps/search/index.py +++ b/apps/search/index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from django.conf import settings -from lucene import SimpleFSDirectory, IndexWriter, IndexWriterConfig, CheckIndex, \ +from lucene import SimpleFSDirectory, NIOFSDirectory, IndexWriter, IndexWriterConfig, CheckIndex, \ File, Field, Integer, \ NumericField, Version, Document, JavaError, IndexSearcher, \ QueryParser, PerFieldAnalyzerWrapper, \ @@ -82,7 +82,7 @@ class IndexStore(object): """ def __init__(self): self.make_index_dir() - self.store = SimpleFSDirectory(File(settings.SEARCH_INDEX)) + self.store = NIOFSDirectory(File(settings.SEARCH_INDEX)) def make_index_dir(self): try: @@ -214,7 +214,7 @@ class Index(BaseIndex): q = NumericRangeQuery.newIntRange("tag_id", 0, Integer.MAX_VALUE, True, True) self.index.deleteDocuments(q) - for tag in catalogue.models.Tag.objects.all(): + for tag in catalogue.models.Tag.objects.exclude(category='set'): doc = Document() doc.add(NumericField("tag_id", Field.Store.YES, True).setIntValue(int(tag.id))) doc.add(Field("tag_name", tag.name, Field.Store.NO, Field.Index.ANALYZED)) @@ -234,7 +234,6 @@ class Index(BaseIndex): for pdtag in PDCounterBook.objects.all(): doc = Document() doc.add(NumericField("tag_id", Field.Store.YES, True).setIntValue(int(pdtag.id))) - print pdtag.title doc.add(Field("tag_name", pdtag.title, Field.Store.NO, Field.Index.ANALYZED)) doc.add(Field("tag_name_pl", pdtag.title, Field.Store.NO, Field.Index.ANALYZED)) doc.add(Field("tag_category", 'pd_book', Field.Store.YES, Field.Index.NOT_ANALYZED)) @@ -651,9 +650,10 @@ class SearchResult(object): self.book_id = int(stored.get("book_id")) pd = stored.get("published_date") - if pd is None: - pd = 0 - self.published_date = int(pd) + try: + self.published_date = int(pd) + except ValueError: + self.published_date = 0 header_type = stored.get("header_type") # we have a content hit in some header of fragment