.gitignore
This commit is contained in:
109
full-text-search/meilisearch/types.go
Normal file
109
full-text-search/meilisearch/types.go
Normal file
@@ -0,0 +1,109 @@
|
||||
// =============================================================================
|
||||
// Meilisearch 数据结构定义
|
||||
// =============================================================================
|
||||
|
||||
package meilisearch
|
||||
|
||||
// SearchParams 搜索参数
|
||||
type SearchParams struct {
|
||||
Query string // 搜索查询字符串
|
||||
Page int64 // 页码(从1开始)
|
||||
Limit int64 // 每页数量
|
||||
Sort []string // 排序字段,如 ["createdAt:desc", "price:asc"]
|
||||
Filter string // 过滤条件
|
||||
SearchableAttributes string // 可搜索字段
|
||||
AttributesToRetrieve []string // 返回字段
|
||||
Facets []string // 聚合字段
|
||||
HitsPerPage int // 每页命中数
|
||||
}
|
||||
|
||||
// SearchResult 搜索结果
|
||||
type SearchResult struct {
|
||||
Hits []map[string]interface{} `json:"hits"`
|
||||
EstimatedTotalHits int64 `json:"estimatedTotalHits"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
ProcessingTimeMs int `json:"processingTimeMs"`
|
||||
Query string `json:"query"`
|
||||
FacetDistribution map[string]interface{} `json:"facetDistribution,omitempty"`
|
||||
}
|
||||
|
||||
// IndexConfig 索引配置
|
||||
type IndexConfig struct {
|
||||
UID string // 索引唯一标识
|
||||
PrimaryKey string // 主键字段名
|
||||
}
|
||||
|
||||
// IndexSettings 索引设置
|
||||
type IndexSettings struct {
|
||||
SearchableAttributes []string `json:"searchableAttributes,omitempty"`
|
||||
DisplayedAttributes []string `json:"displayedAttributes,omitempty"`
|
||||
FilterableAttributes []string `json:"filterableAttributes,omitempty"`
|
||||
SortableAttributes []string `json:"sortableAttributes,omitempty"`
|
||||
RankingRules []string `json:"rankingRules,omitempty"`
|
||||
StopWords []string `json:"stopWords,omitempty"`
|
||||
Synonyms map[string][]string `json:"synonyms,omitempty"`
|
||||
DistinctAttribute string `json:"distinctAttribute,omitempty"`
|
||||
TypoTolerance *TypoTolerance `json:"typoTolerance,omitempty"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
Faceting *Faceting `json:"faceting,omitempty"`
|
||||
}
|
||||
|
||||
// TypoTolerance 拼写容错设置
|
||||
type TypoTolerance struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
MinWordSizeForTypos map[string]int `json:"minWordSizeForTypos"`
|
||||
DisableOnWords []string `json:"disableOnWords"`
|
||||
DisableOnAttributes []string `json:"disableOnAttributes"`
|
||||
}
|
||||
|
||||
// Pagination 分页设置
|
||||
type Pagination struct {
|
||||
MaxTotalHits int `json:"maxTotalHits"`
|
||||
}
|
||||
|
||||
// Faceting 聚合设置
|
||||
type Faceting struct {
|
||||
MaxValuesPerFacet int `json:"maxValuesPerFacet"`
|
||||
}
|
||||
|
||||
// TaskResult 任务结果
|
||||
type TaskResult struct {
|
||||
TaskUID int64 `json:"taskUid"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Document 文档
|
||||
type Document map[string]interface{}
|
||||
|
||||
// 文档操作符
|
||||
const (
|
||||
OperatorEquals = "="
|
||||
OperatorNotEquals = "!="
|
||||
OperatorGreaterThan = ">"
|
||||
OperatorGreaterOrEqual = ">="
|
||||
OperatorLessThan = "<"
|
||||
OperatorLessOrEqual = "<="
|
||||
OperatorAnd = "AND"
|
||||
OperatorOr = "OR"
|
||||
OperatorNot = "NOT"
|
||||
)
|
||||
|
||||
// 排序顺序
|
||||
const (
|
||||
SortAsc = "asc"
|
||||
SortDesc = "desc"
|
||||
)
|
||||
|
||||
// 排名规则
|
||||
const (
|
||||
RankingRuleWords = "words"
|
||||
RankingRuleTypo = "typo"
|
||||
RankingRuleProximity = "proximity"
|
||||
RankingRuleAttribute = "attribute"
|
||||
RankingRuleSort = "sort"
|
||||
RankingRuleExactness = "exactness"
|
||||
)
|
||||
Reference in New Issue
Block a user