feat: multiple search indexes (#2514)
* refactor: abstract search interface * wip: ~ * fix cycle import * objs update hook * wip: ~ * Delete search/none * auto update index while cache changed * db searcher TODO: bleve init issue cannot open index, metadata missing * fix size type why float64?? * fix typo * fix nil pointer using * api adapt ui * bleve: fix clear & change struct
This commit is contained in:
36
internal/model/search.go
Normal file
36
internal/model/search.go
Normal file
@ -0,0 +1,36 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type IndexProgress struct {
|
||||
ObjCount uint64 `json:"obj_count"`
|
||||
IsDone bool `json:"is_done"`
|
||||
LastDoneTime *time.Time `json:"last_done_time"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
type SearchReq struct {
|
||||
Parent string `json:"parent"`
|
||||
Keywords string `json:"keywords"`
|
||||
PageReq
|
||||
}
|
||||
|
||||
type SearchNode struct {
|
||||
Parent string `json:"parent" gorm:"index"`
|
||||
Name string `json:"name" gorm:"index"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (p *SearchReq) Validate() error {
|
||||
if p.Page < 1 {
|
||||
return fmt.Errorf("page can't < 1")
|
||||
}
|
||||
if p.PerPage < 1 {
|
||||
return fmt.Errorf("per_page can't < 1")
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user