Rebuild search index in admin options (#647)

Signed-off-by: Thomas Miceli <tho.miceli@gmail.com>
This commit is contained in:
Thomas Miceli
2026-03-09 06:30:28 +07:00
committed by GitHub
parent a697b0f273
commit f8b3bbce6a
16 changed files with 71 additions and 25 deletions

View File

@@ -2,6 +2,8 @@ package index
import (
"errors"
"fmt"
"os"
"strconv"
"github.com/blevesearch/bleve/v2"
@@ -82,6 +84,15 @@ func (i *BleveIndexer) open() (bleve.Index, error) {
return bleve.New(i.path, mapping)
}
func (i *BleveIndexer) Reset() error {
i.Close()
if err := os.RemoveAll(i.path); err != nil {
return fmt.Errorf("failed to remove Bleve index directory: %w", err)
}
log.Info().Msg("Bleve index directory removed, re-creating index")
return i.Init()
}
func (i *BleveIndexer) Close() {
if i == nil || i.index == nil {
return