Faster indexing and a couple of correctness fixes.
Performance
- SQLite index creation is ~3× faster.
saveWordlist()no longer inserts each term and catches aUNIQUE-constraint exception (re-preparing every statement per duplicate term); it uses a singleINSERT … ON CONFLICT(term) DO UPDATEupsert and resolves term ids withoutSELECT MAX(id). insert()is ~25× faster for large documents. Each document is now indexed inside a single transaction instead of one implicit commit (fsync) per wordlist/doclist write — so indexing e.g. a PDF perinsert()call no longer pays thousands of fsyncs. (#360)
Fixed
total_documentswas left at0when the number of indexed rows was an exact multiple of the 10,000-row commit batch, because the final transaction was left open and the info-table update rolled back. This corrupted BM25idf = log(count / df)for such indexes.MysqlEnginewordlist upsert accumulatednum_hitsusing the document count instead of the hit count, giving multi-document terms the wrong total occurrence count.
Added
- A
benchmark/harness (seeded Zipfian dataset generator + timers) for measuring index-creation speed.
Full Changelog: v5.2.0...v5.3.0