query

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 6 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 natural language text. terms 作为自然语言查询(Text)传递,同时作为原始搜索词保留在 BaseQuery 中。

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 // 关系类型过滤(可选),空表示不过滤
	// 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) 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) 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.

Jump to

Keyboard shortcuts

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