Mercurial > code > home > repos > sco-bot
view scobot/index/access.py @ 11:6622bacb0b84
first pass at reorg
author | drewp@bigasterisk.com |
---|---|
date | Thu, 11 Jul 2024 18:15:44 -0700 |
parents | flow/search_index.py@13438795d896 |
children | 403eff4a16c8 |
line wrap: on
line source
from pathlib import Path from whoosh.index import create_in from scobot.index.schema import schema log = None # set by flow class SearchIndex: def __init__(self, indexDir: Path): indexDir.mkdir(parents=True, exist_ok=True) self.ix = create_in(indexDir, schema) self.writer = self.ix.writer() def addDoc(self, **kw): self.writer.add_document(**kw) def commit(self): self.writer.commit() with self.ix.searcher() as searcher: log.info(f'index doc count = {searcher.doc_count()}')