Documentation
¶
Index ¶
- Variables
- func FormatFileSize(size int64) string
- func Hits(text string, words []string) []*pb.Hit
- func Index(lower, str, word string) (int, int)
- func IsWord(r rune) bool
- func NewDB(config *Config) level.DB
- func Size(file string) int64
- func Split(txt string) sets.Strings
- func SplitWord(elems []string) sets.Strings
- func WordsMay(words string) []string
- type App
- type Config
- type FileService
- func (p *FileService) Delete(file string)
- func (p *FileService) File(file string) (*pb.File, bool)
- func (p *FileService) FileByWord(ids []uint32) []uint32
- func (p *FileService) Files(ids []uint32) []*pb.File
- func (p *FileService) FilesByStart(start string) []*pb.File
- func (p *FileService) Hit(file *pb.File, words []string)
- func (p *FileService) Tag(fid uint32, ts tags.Tags)
- type IndexData
- type Indexs
- type Service
- func (p *Service) Close() error
- func (p *Service) FileInfo(file string) *pb.File
- func (p *Service) FindWords(fileIDs []uint32, words string) []uint32
- func (p *Service) Index(path string)
- func (p *Service) Min()
- func (p *Service) Reindex()
- func (p *Service) Search(wordses []string) []*pb.File
- func (p *Service) WordInfo(word string) *pb.Word
- func (p *Service) WordList(start string) []*pb.Word
- type WordService
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFileChange = errors.New("文件发生修改,请索引")
ErrFileChange 文件发生修改.
Functions ¶
func FormatFileSize ¶
FormatFileSize 格式化文件尺寸.
Example ¶
package main import ( "fmt" "gitee.com/xuender/se" ) func main() { fmt.Println(se.FormatFileSize(2048)) fmt.Println(se.FormatFileSize(2)) fmt.Println(se.FormatFileSize(71002048)) fmt.Println(se.FormatFileSize(1024*1024*1024 + 1)) fmt.Println(se.FormatFileSize(1024 * 1024 * 1024 * 1024 * 5)) fmt.Println(se.FormatFileSize(1024 * 1024 * 1024 * 1024 * 1024 * 5)) }
Output: 2KB 2B 67.71MB 1.00GB 5.00TB 5.00EB
Types ¶
type Config ¶
type Config struct { DataBasePath string Deploy bool Limit uint `toml:"-"` Offset uint `toml:"-"` Start string `toml:"-"` Exts []string Ignore []string PassDir bool }
Config 设置.
type FileService ¶ added in v1.0.3
type FileService struct {
// contains filtered or unexported fields
}
FileService 文件服务.
func NewFileService ¶ added in v1.0.3
func NewFileService( config *Config, ls *level.Service, ) *FileService
NewFileService 新建文件服务.
func (*FileService) File ¶ added in v1.0.3
func (p *FileService) File(file string) (*pb.File, bool)
File 生成文件信息.
func (*FileService) FileByWord ¶ added in v1.0.3
func (p *FileService) FileByWord(ids []uint32) []uint32
FileByWord 根据词ID查找文件信息.
func (*FileService) Files ¶ added in v1.0.3
func (p *FileService) Files(ids []uint32) []*pb.File
Files 根据文件ID返回文件信息.
func (*FileService) FilesByStart ¶ added in v1.0.3
func (p *FileService) FilesByStart(start string) []*pb.File
FilesByStart 索引文件列表.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 搜索引擎服务.
func NewService ¶
func NewService( config *Config, ls *level.Service, fs *FileService, ws *WordService, ) *Service
NewService 新建搜索引擎服务.
type WordService ¶ added in v1.0.3
type WordService struct {
// contains filtered or unexported fields
}
WordService 词服务.
func NewWordService ¶ added in v1.0.3
func NewWordService(ls *level.Service) *WordService
NewWordService 新建词服务.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.