query

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFulltextQuery

func NewFulltextQuery(terms string) core.Query

FulltextQuery creates a new fulltext query from the given terms.

func NewGraphQuery

func NewGraphQuery(terms string) core.Query

NewGraphQuery creates a new graph query from the given terms.

func NewSemanticQuery

func NewSemanticQuery(terms string, embedder core.Embedder) core.Query

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

func (q *BaseQuery) AddFilter(key string, value any) core.Query

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

func (q *BaseQuery) Filters() map[string]any

Filters returns the filters to apply to the search.

Returns:

  • map[string]any: The filters

func (*BaseQuery) Keywords

func (q *BaseQuery) Keywords() []string

Keywords returns the extracted keywords from the query.

Returns:

  • []string: The extracted keywords

func (*BaseQuery) Raw

func (q *BaseQuery) Raw() string

Raw returns the raw, unprocessed query string.

Returns:

  • string: The raw query string

type FulltextQuery

type FulltextQuery struct {
	BaseQuery
}

FulltextQuery 全文查询

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) SetDepth

func (q *GraphQuery) SetDepth(depth int)

SetDepth 设置图遍历深度

func (*GraphQuery) SetEdgeTypes

func (q *GraphQuery) SetEdgeTypes(types []string)

SetEdgeTypes 设置关系类型过滤(仅遍历指定类型的边)

func (*GraphQuery) SetLimit

func (q *GraphQuery) SetLimit(limit int)

SetLimit 设置返回结果数量限制

func (*GraphQuery) SetMode

func (q *GraphQuery) SetMode(mode core.SearchMode)

SetMode 设置搜索模式

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 NewQueryRouter

func NewQueryRouter() *QueryRouter

NewQueryRouter 创建查询路由器,使用默认关键词配置

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.

Jump to

Keyboard shortcuts

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