Record statistics on how many bookmarks and words are indexed, and the number of searches performed.

This commit is contained in:
2022-08-20 23:44:47 +09:30
parent c5957e38db
commit ccf373b863
6 changed files with 144 additions and 7 deletions

View File

@@ -20,7 +20,20 @@ func (db *DB) UpdateIndexForWordsByID(words []string, id uint64) {
}
db.store.TxForEach(txn, &bolthold.Query{}, func(wi *entity.WordIndex) error {
delete(wi.Bitmap, id)
db.store.TxUpdate(txn, "word_index_"+wi.Word, wi)
// if the index is now completely empty, nuke it entirely
empty := true
for _, v := range wi.Bitmap {
if v {
empty = false
break
}
}
if empty {
db.store.TxDelete(txn, "word_index_"+wi.Word, wi)
} else {
db.store.TxUpdate(txn, "word_index_"+wi.Word, wi)
}
return nil
})