Rebuild search index in admin options (#647)
Signed-off-by: Thomas Miceli <tho.miceli@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user