commit 2fadb34b7487549e9b085dc0943cd923efe1c07b
parent 0b4062ed4d72021f1bf2cbbbcb89c86fe7634f01
Author: René Wagner <rwa@clttr.info>
Date: Fri, 9 Dec 2022 21:19:43 +0100
only use whoosh multisegments when indexing from scratch
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gus/lib/search.py b/gus/lib/search.py
@@ -14,8 +14,9 @@ from gus.lib.whoosh_extensions import UrlAnalyzer, GeminiFormatter, GeminiScorer
class Index:
def __init__(self, index_dir, should_run_destructive=False):
index_storage = FileStorage(index_dir, supports_mmap=False)
+ self._destructive = should_run_destructive
- if should_run_destructive:
+ if self._destructive:
pathlib.Path(index_dir).mkdir(parents=True, exist_ok=True)
self._index = self._create(index_storage)
else:
@@ -76,7 +77,7 @@ class Index:
def _rolling_writer(self):
if not self._writer:
- self._writer = self._index.writer(limitmb=1024, procs=3, multisegment=True)
+ self._writer = self._index.writer(limitmb=1024, procs=3, multisegment=self._destructive)
return self._writer
def add_document(self, document):