Help us shape the future of Go! Take the 2026 Go Developer Survey

search

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntityLimit   = 5  // 每类实体最多返回数
	RagTopK       = 8  // RAG 返回数
	ContentLimit  = 10 // 正文精确匹配最多返回数
	ContextRadius = 15 // 命中上下文半径(中文字符),mark 居中简短
)

搜索参数常量

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Type          string  `json:"type"`           // character / location / timeline / storyarc / chapter / content / rag
	ID            int64   `json:"id"`             // 实体 ID(content/rag 为 0)
	Title         string  `json:"title"`          // 主显示名
	Subtitle      string  `json:"subtitle"`       // 副标题(类型标签等)
	ChapterNum    int     `json:"chapter_num"`    // 关联章节号
	FilePath      string  `json:"file_path"`      // 章节文件路径
	MatchPrefix   string  `json:"match_prefix"`   // 命中前上下文(纯文本)
	MatchHit      string  `json:"match_hit"`      // 命中的文本(纯文本)
	MatchSuffix   string  `json:"match_suffix"`   // 命中后上下文(纯文本)
	MatchPosition int     `json:"match_position"` // 命中 rune 偏移,用于编辑器定位
	MatchLen      int     `json:"match_len"`      // 命中长度(rune),精确搜索=关键词长,RAG=chunk长
	Relevance     float64 `json:"relevance"`      // 相关度 0-1(精确搜索为 1)
	PanelID       string  `json:"panel_id"`       // 跳转目标面板 ID
}

Result 是统一搜索结果的单条记录。

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service 协调全局搜索:实体 LIKE + 正文精确 + RAG 语义。 缓存章节正文在内存中,避免重复读文件。

func NewService

func NewService(logger *slog.Logger, charStore *character.Store, locStore *location.Store,
	tlStore *timeline.Store, arcStore *storyarc.Store, chapStore *chapter.Store,
	readerStore *reader.Store, prefStore *preference.Store, settingStore *setting.Store,
	vecStore *rag.VectorStore) *Service

NewService 创建搜索服务。

func (*Service) SearchAll

func (s *Service) SearchAll(ctx context.Context, novelID int64, query string) ([]Result, error)

SearchAll 执行全局搜索,并发执行三类搜索后合并结果。

func (*Service) UpdateCachedChapter

func (s *Service) UpdateCachedChapter(novelID int64, chapterNum int, newContent string)

UpdateCachedChapter 在章节保存后更新缓存中的对应章节内容。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL