Documentation
¶
Index ¶
- Constants
- func BM25Rank(field, query string) string
- func BM25Score(field, query string) string
- func FulltextBooleanSQL(clause BooleanClause, minShouldMatch int, boost float64) string
- func FulltextBoost(query string, boost float64) string
- func FulltextDisjunctionMax(queries []string, tieBreaker, boost float64) string
- func FulltextExists(field string, boost float64) string
- func FulltextFuzzy(field, term string, distance int, boost float64) string
- func FulltextNested(path, query string, boost float64) string
- func FulltextPhrase(field string, terms []string, slop int, boost float64) string
- func FulltextPhrasePrefix(field string, terms []string, boost float64) string
- func FulltextPrefix(field, prefix string, boost float64) string
- func FulltextRange(field, min, max string, includeMin, includeMax bool, boost float64) string
- func FulltextRegex(field, pattern string, boost float64) string
- func FulltextTerm(field, value string, boost float64) string
- func FulltextWildcard(field, wildcard string, boost float64) string
- func Highlight(field, query, preTag, postTag string) string
- func HighlightMulti(field, query, preTag, postTag string, numFragments, fragmentLen int) string
- func HybridRank(field, vectorField, query, vector string) string
- func HybridScore(ftScore, vecScore string, ftWeight, vecWeight float64) string
- func RRFRank(ranks []string, k int) string
- func Tokenize(tokenizer, text string) string
- type BooleanClause
- type FulltextConfig
- type FulltextField
- type FulltextTokenizer
- func (t *FulltextTokenizer) ToSQL() string
- func (t *FulltextTokenizer) WithDict(path string) *FulltextTokenizer
- func (t *FulltextTokenizer) WithHMM(hmm bool) *FulltextTokenizer
- func (t *FulltextTokenizer) WithNgram(minGram, maxGram int, prefixOnly bool) *FulltextTokenizer
- func (t *FulltextTokenizer) WithSearchMode(search bool) *FulltextTokenizer
- func (t *FulltextTokenizer) WithStopWords(path string) *FulltextTokenizer
- type SQLGenerator
Constants ¶
const ( QueryTypeTerm = "term" QueryTypePhrase = "phrase" QueryTypePhrasePrefix = "phrase_prefix" QueryTypeFuzzy = "fuzzy" QueryTypeRegex = "regex" QueryTypeRange = "range" QueryTypeBoolean = "boolean" QueryTypeDisjunctionMax = "disjunction_max" QueryTypeConstScore = "const_score" QueryTypeEmpty = "empty" QueryTypeTermSet = "term_set" QueryTypePrefix = "prefix" QueryTypeWildcard = "wildcard" QueryTypeExists = "exists" QueryTypeNested = "nested" )
QueryType 查询类型
Variables ¶
This section is empty.
Functions ¶
func FulltextBooleanSQL ¶
func FulltextBooleanSQL(clause BooleanClause, minShouldMatch int, boost float64) string
FulltextBooleanSQL 生成布尔查询SQL
func FulltextBoost ¶
FulltextBoost 提升查询函数 示例: fulltext_boost(query, 2.0)
func FulltextDisjunctionMax ¶
FulltextDisjunctionMax 析取最大查询函数 示例: fulltext_disjunction_max(ARRAY[q1, q2], tie_breaker=>0.3)
func FulltextExists ¶
FulltextExists 字段存在查询函数 示例: fulltext_exists('field')
func FulltextFuzzy ¶
FulltextFuzzy 模糊查询函数 示例: fulltext_fuzzy('field', 'term', distance=>2)
func FulltextNested ¶
FulltextNested 嵌套查询函数(用于JSON字段) 示例: fulltext_nested('metadata', fulltext_term('color', 'red'))
func FulltextPhrase ¶
FulltextPhrase 短语查询函数 示例: fulltext_phrase('field', ARRAY['word1', 'word2'], slop=>0)
func FulltextPhrasePrefix ¶
FulltextPhrasePrefix 短语前缀查询函数 示例: fulltext_phrase_prefix('field', ARRAY['word1', 'word2'])
func FulltextPrefix ¶
FulltextPrefix 前缀查询函数 示例: fulltext_prefix('field', 'prefix')
func FulltextRange ¶
FulltextRange 范围查询函数 示例: fulltext_range('field', '2023-01-01', '2024-12-31')
func FulltextRegex ¶
FulltextRegex 正则查询函数 示例: fulltext_regex('field', 'pattern')
func FulltextTerm ¶
FulltextTerm 词项查询函数 示例: fulltext_term('field', 'value', boost=>2.0)
func FulltextWildcard ¶
FulltextWildcard 通配符查询函数 示例: fulltext_wildcard('field', 'prefix*')
func HighlightMulti ¶
HighlightMulti 多片段高亮函数 示例: highlight_multi(content, '关键词', '<mark>', '</mark>', 3, 150)
func HybridRank ¶
HybridRank 混合排名函数 示例: hybrid_rank(content, embedding, '关键词', '[0.1, 0.2, ...]')
func HybridScore ¶
HybridScore 混合分数函数 示例: hybrid_score(ft_score, vec_score, ft_weight=>0.7, vec_weight=>0.3)
Types ¶
type BooleanClause ¶
BooleanClause 布尔查询子句
type FulltextConfig ¶
type FulltextConfig struct {
Query string
EnableHybrid bool
FusionStrategy string
FTWeight float64
VecWeight float64
}
FulltextConfig 查询配置函数 示例: fulltext_config('field:term^2 AND field2:term3')
func NewFulltextConfig ¶
func NewFulltextConfig(query string) *FulltextConfig
NewFulltextConfig 创建查询配置
func (*FulltextConfig) WithHybrid ¶
func (c *FulltextConfig) WithHybrid(strategy string, ftWeight, vecWeight float64) *FulltextConfig
WithHybrid 启用混合搜索
type FulltextField ¶
type FulltextField struct {
Name string
Fast bool
Tokenizer string
Record string
FieldNorms bool
Boost float64
}
FulltextField 字段配置函数(SQL函数式配置) 示例: fulltext_field('content', fast=>FALSE, tokenizer=>'jieba')
func (*FulltextField) WithBoost ¶
func (f *FulltextField) WithBoost(boost float64) *FulltextField
WithBoost 设置权重
func (*FulltextField) WithFast ¶
func (f *FulltextField) WithFast(fast bool) *FulltextField
WithFast 设置Fast选项
func (*FulltextField) WithRecord ¶
func (f *FulltextField) WithRecord(record string) *FulltextField
WithRecord 设置记录类型
func (*FulltextField) WithTokenizer ¶
func (f *FulltextField) WithTokenizer(tokenizer string) *FulltextField
WithTokenizer 设置分词器
type FulltextTokenizer ¶
type FulltextTokenizer struct {
Type string
HMM bool
SearchMode bool
DictPath string
StopWordsPath string
MinGram int
MaxGram int
PrefixOnly bool
}
FulltextTokenizer 分词器配置函数 示例: fulltext_tokenizer('jieba', hmm=>TRUE, search=>TRUE)
func NewFulltextTokenizer ¶
func NewFulltextTokenizer(tokenizerType string) *FulltextTokenizer
NewFulltextTokenizer 创建分词器配置
func (*FulltextTokenizer) WithDict ¶
func (t *FulltextTokenizer) WithDict(path string) *FulltextTokenizer
WithDict 设置词典路径
func (*FulltextTokenizer) WithHMM ¶
func (t *FulltextTokenizer) WithHMM(hmm bool) *FulltextTokenizer
WithHMM 设置HMM
func (*FulltextTokenizer) WithNgram ¶
func (t *FulltextTokenizer) WithNgram(minGram, maxGram int, prefixOnly bool) *FulltextTokenizer
WithNgram 设置N-gram参数
func (*FulltextTokenizer) WithSearchMode ¶
func (t *FulltextTokenizer) WithSearchMode(search bool) *FulltextTokenizer
WithSearchMode 设置搜索模式
func (*FulltextTokenizer) WithStopWords ¶
func (t *FulltextTokenizer) WithStopWords(path string) *FulltextTokenizer
WithStopWords 设置停用词路径
type SQLGenerator ¶
type SQLGenerator struct {
SelectColumns []string
FromTable string
WhereField string
Query string
OrderBy string
Limit int
Offset int
}
SQLGenerator SQL生成器
func NewSQLGenerator ¶
func NewSQLGenerator(table, field, query string) *SQLGenerator
NewSQLGenerator 创建SQL生成器
func (*SQLGenerator) BuildWithScore ¶
func (g *SQLGenerator) BuildWithScore() string
BuildWithScore 生成带分数的SQL
func (*SQLGenerator) OrderByScore ¶
func (g *SQLGenerator) OrderByScore(desc bool) *SQLGenerator
OrderByScore 设置按分数排序
func (*SQLGenerator) Paginate ¶
func (g *SQLGenerator) Paginate(limit, offset int) *SQLGenerator
Paginate 设置分页
func (*SQLGenerator) Select ¶
func (g *SQLGenerator) Select(columns ...string) *SQLGenerator
Select 设置查询列