From cdf0ea700156d13cd27a670d9363d92ebaffa93f Mon Sep 17 00:00:00 2001
From: Marcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Date: Thu, 10 Nov 2011 16:57:44 +0100
Subject: [PATCH] paralell indexing

---
 apps/catalogue/models.py | 9 ++++++++-
 wolnelektury/settings.py | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py
index 0863d5b66..1a2e8f86f 100644
--- a/apps/catalogue/models.py
+++ b/apps/catalogue/models.py
@@ -626,7 +626,14 @@ class Book(models.Model):
         return result.wait()
 
     def search_index(self):
-        idx = search.ReusableIndex()
+        if settings.SEARCH_INDEX_PARALLEL:
+            if instance(settings.SEARCH_INDEX_PARALLEL, int):
+                idx = search.ReusableIndex(threads=4)
+            else:
+                idx = search.ReusableIndex()
+        else:
+            idx = search.Index()
+            
         idx.open()
         try:
             idx.index_book(self)
diff --git a/wolnelektury/settings.py b/wolnelektury/settings.py
index c0baf9990..ca0678455 100644
--- a/wolnelektury/settings.py
+++ b/wolnelektury/settings.py
@@ -234,6 +234,7 @@ NO_BUILD_TXT = False
 NO_BUILD_PDF = True
 NO_BUILD_MOBI = True
 NO_SEARCH_INDEX = False
+SEARCH_INDEX_PARALLEL = False
 
 ALL_EPUB_ZIP = 'wolnelektury_pl_epub'
 ALL_PDF_ZIP = 'wolnelektury_pl_pdf'
-- 
2.20.1