Documentation
¶
Index ¶
- func NewFulltextQuery(terms string) core.Query
- func NewGraphQuery(terms string) core.Query
- func NewSemanticQuery(terms string, embedder core.Embedder) core.Query
- func NewTreeQuery(regionID string, depth int) core.Query
- type BaseQuery
- type FulltextQuery
- type GraphQuery
- func (q *GraphQuery) RawCypher() string
- func (q *GraphQuery) SetDepth(depth int)
- func (q *GraphQuery) SetEdgeTypes(types []string)
- func (q *GraphQuery) SetLimit(limit int)
- func (q *GraphQuery) SetRawCypher(cypher string)
- func (q *GraphQuery) SetTextQuery(text string)
- func (q *GraphQuery) TextQuery() string
- type SemanticQuery
- type TreeQuery
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 natural language text. terms 作为自然语言查询(Text)传递,同时作为原始搜索词保留在 BaseQuery 中。
func NewSemanticQuery ¶
NewSemanticQuery creates a new semantic 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 // 关系类型过滤(可选),空表示不过滤
// contains filtered or unexported fields
}
GraphQuery 图查询
支持两种查询模式:
- Text:自然语言描述,由 GraphIndexer 内部 LLM 自动生成 Cypher 执行
- Raw:直接提供原生 Cypher 语句,GraphIndexer 不做转换直接执行
如果 Text 和 Raw 都为空,GraphIndexer 走默认的语义向量检索 + 图融合路径。
func (*GraphQuery) RawCypher ¶
func (q *GraphQuery) RawCypher() string
RawCypher 返回原生 Cypher 查询语句。 非空时,GraphIndexer 直接将其交给 graphDB 执行。
func (*GraphQuery) SetEdgeTypes ¶
func (q *GraphQuery) SetEdgeTypes(types []string)
SetEdgeTypes 设置关系类型过滤(仅遍历指定类型的边)
func (*GraphQuery) SetRawCypher ¶
func (q *GraphQuery) SetRawCypher(cypher string)
SetRawCypher 设置原生 Cypher 查询语句。 GraphIndexer 会在 Search 时直接执行此语句。
func (*GraphQuery) SetTextQuery ¶
func (q *GraphQuery) SetTextQuery(text string)
SetTextQuery 设置自然语言查询文本。 GraphIndexer 会在 Search 时使用内部 LLM 将其转换为 Cypher。
func (*GraphQuery) TextQuery ¶
func (q *GraphQuery) TextQuery() string
TextQuery 返回自然语言查询文本。 非空时,GraphIndexer 会使用内部 LLM 将其转换为 Cypher 再执行。
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.