Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFulltextQuery ¶
FulltextQuery creates a new fulltext query from the given terms.
func NewGraphQuery ¶
NewGraphQuery creates a new graph query from the given terms.
Types ¶
type BaseQuery ¶
type BaseQuery struct {
// contains filtered or unexported fields
}
BaseQuery is a default implementation of the core.Query interface.
func (*BaseQuery) AddFilter ¶
AddFilter adds a filter to the query. The value is copied to prevent external modification.
Parameters:
- key: The filter key
- value: The filter value
Returns:
- core.Query: The query with the added filter
func (*BaseQuery) Filters ¶
Filters returns the filters to apply to the search.
Returns:
- map[string]any: The filters
type GraphQuery ¶
type GraphQuery struct {
BaseQuery
Depth int
Limit int
EdgeTypes []string // 关系类型过滤(可选),空表示不过滤
Mode core.SearchMode // 搜索模式: "local" | "global" | "hybrid"
// contains filtered or unexported fields
}
GraphQuery 图查询
func (*GraphQuery) Cypher ¶
func (q *GraphQuery) Cypher() string
Cypher 返回 Text2Cypher 生成的 Cypher 查询语句
func (*GraphQuery) SetEdgeTypes ¶
func (q *GraphQuery) SetEdgeTypes(types []string)
SetEdgeTypes 设置关系类型过滤(仅遍历指定类型的边)
func (*GraphQuery) Text2Cypher ¶
func (q *GraphQuery) Text2Cypher(client chat.Client) error
Text2Cypher 将自然语言查询转换为 Cypher 图查询语句 使用 LLM 理解用户意图并生成对应的 Cypher 查询 生成的 Cypher 应返回与实体/关系相关的节点和边信息
type QueryRouter ¶
type QueryRouter struct {
// contains filtered or unexported fields
}
QueryRouter 查询路由器 根据查询特征自动选择最合适的搜索模式
func (*QueryRouter) IsGlobalQuery ¶
func (r *QueryRouter) IsGlobalQuery(query string) bool
IsGlobalQuery 快速判断是否为全局查询
func (*QueryRouter) IsHybridQuery ¶
func (r *QueryRouter) IsHybridQuery(query string) bool
IsHybridQuery 快速判断是否为混合查询
func (*QueryRouter) Route ¶
func (r *QueryRouter) Route(query string) core.SearchMode
Route 根据查询文本自动选择搜索模式
type SemanticQuery ¶
type SemanticQuery struct {
BaseQuery
Embedder core.Embedder // 向量编码器,用于语义相似度计算
// contains filtered or unexported fields
}
SemanticQuery 语义查询
func (*SemanticQuery) Expansion ¶
func (q *SemanticQuery) Expansion(client chat.Client) error
Expansion 查询扩展:生成多个相关查询变体,扩大检索范围 适用于查询词过于狭窄或模糊的场景
func (*SemanticQuery) HyDe ¶
func (q *SemanticQuery) HyDe(client chat.Client) error
HyDe 假设式文档查询:生成一个假设性的文档来回答查询 适用于需要语义匹配但缺乏精确关键词的场景
func (*SemanticQuery) Rewriting ¶
func (q *SemanticQuery) Rewriting(client chat.Client) error
Rewriting 查询重写:将模糊或不明确的查询改写为更清晰的形式 适用于口语化、模糊或不完整的查询
func (*SemanticQuery) Vector ¶
func (q *SemanticQuery) Vector() *core.Vector
Vector returns the vector representations of the query.