importbooks / tasks for indexing
[wolnelektury.git] / apps / search / index.py
index 4962cae..da54fe7 100644 (file)
@@ -111,7 +111,7 @@ class Index(SolrIndex):
     Class indexing books.
     """
     def __init__(self):
     Class indexing books.
     """
     def __init__(self):
-        super(Index, self).__init__()
+        super(Index, self).__init__(mode='rw')
 
     def delete_query(self, *queries):
         """
 
     def delete_query(self, *queries):
         """
@@ -201,6 +201,7 @@ class Index(SolrIndex):
                         "is_pdcounter": False,
                         "uid": "tag%d" % tag.id
                         }
                         "is_pdcounter": False,
                         "uid": "tag%d" % tag.id
                         }
+                print "ADD 1 %s" % doc
                 self.index.add(doc)
 
     def create_book_doc(self, book):
                 self.index.add(doc)
 
     def create_book_doc(self, book):
@@ -249,6 +250,7 @@ class Index(SolrIndex):
             book_doc[n] = f
 
         book_doc['uid'] = "book%s" % book_doc['book_id']
             book_doc[n] = f
 
         book_doc['uid'] = "book%s" % book_doc['book_id']
+        print "ADD 2 %s" % book_doc
         self.index.add(book_doc)
         del book_doc
         book_fields = {
         self.index.add(book_doc)
         del book_doc
         book_fields = {
@@ -460,7 +462,7 @@ class Index(SolrIndex):
                         doc = add_part(snippets, header_index=position, header_type=header.tag,
                                        text=u''.join(footnote),
                                        is_footnote=True)
                         doc = add_part(snippets, header_index=position, header_type=header.tag,
                                        text=u''.join(footnote),
                                        is_footnote=True)
-
+                        print "ADD 3 %s" % doc
                         self.index.add(doc)
                         #print "@ footnote text: %s" % footnote
                         footnote = []
                         self.index.add(doc)
                         #print "@ footnote text: %s" % footnote
                         footnote = []
@@ -496,6 +498,7 @@ class Index(SolrIndex):
                                        text=fix_format(frag['text']),
                                        themes=frag['themes'])
                         #print '@ FRAG %s' % frag['content']
                                        text=fix_format(frag['text']),
                                        themes=frag['themes'])
                         #print '@ FRAG %s' % frag['content']
+                        print "ADD 4 %s" % doc
                         self.index.add(doc)
 
                         # Collect content.
                         self.index.add(doc)
 
                         # Collect content.
@@ -510,6 +513,7 @@ class Index(SolrIndex):
                                header_type=header.tag, text=fix_format(content))
                 #print '@ CONTENT: %s' % fix_format(content)
 
                                header_type=header.tag, text=fix_format(content))
                 #print '@ CONTENT: %s' % fix_format(content)
 
+                print "ADD 5 %s" % doc
                 self.index.add(doc)
 
         finally:
                 self.index.add(doc)
 
         finally:
@@ -722,7 +726,7 @@ class Search(SolrIndex):
     Search facilities.
     """
     def __init__(self, default_field="text"):
     Search facilities.
     """
     def __init__(self, default_field="text"):
-        super(Search, self).__init__()
+        super(Search, self).__init__(mode='r')
 
     # def get_tokens(self, searched, field='text', cached=None):
     #     """returns tokens analyzed by a proper (for a field) analyzer
 
     # def get_tokens(self, searched, field='text', cached=None):
     #     """returns tokens analyzed by a proper (for a field) analyzer