Documentation ¶
Index ¶
- Constants
- func BulkAddDocument(es *database.Es, ctx context.Context, params ...any) bool
- func BulkDeleteDocument(es *database.Es, ctx context.Context, params ...any) bool
- func CreateDocument(es *database.Es, ctx context.Context, params ...any) bool
- func CreateIndex(es *database.Es, ctx context.Context, params ...any) bool
- func DeleteDocument(es *database.Es, ctx context.Context, params ...any) bool
- func DeleteIndex(es *database.Es, ctx context.Context, index string) bool
- func GetStructTag(t any) esTags
- func HasIndex(es *database.Es, ctx context.Context, index string) bool
- func PutMappingByStruct(es *database.Es, ctx context.Context, params ...any) bool
- func SearchAggregations(es *database.Es, ctx context.Context, params ...any) (map[string]types.Aggregate, error)
- func SearchDocument(es *database.Es, ctx context.Context, params ...any) (any, error)
- func UpdateDocument(es *database.Es, ctx context.Context, params ...any) bool
- type ElasticSearchPage
- type GormPage
- type NativeSqlPage
Constants ¶
View Source
const ( EsType = "es_type" EsAnalyzer = "es_analyzer" Json = "json" )
Variables ¶
This section is empty.
Functions ¶
func BulkAddDocument ¶
BulkAddDocument 批量添加文档
func BulkDeleteDocument ¶
BulkDeleteDocument 批量删除文档
func CreateDocument ¶
CreateDocument 添加单个文档
func CreateIndex ¶
CreateIndex 创建索引
func DeleteDocument ¶
DeleteDocument 根据文档 id 删除文档
func DeleteIndex ¶
DeleteIndex 删除索引
func GetStructTag ¶
func GetStructTag(t any) esTags
GetStructTag 获取结构体的 elasticsearch 标签 Deprecated: 弃用
func PutMappingByStruct ¶
PutMappingByStruct 根据结构体更新 mapping
func SearchAggregations ¶
func SearchAggregations(es *database.Es, ctx context.Context, params ...any) (map[string]types.Aggregate, error)
SearchAggregations 聚合数据查询
func SearchDocument ¶
SearchDocument 根据索引名 index 和 search.Request 条件查询文档
Types ¶
type ElasticSearchPage ¶
type ElasticSearchPage struct { *database.Es Index string // 用于构建 searchRequest 例如:searchRequest.Query = &types.Query{MatchAll: &types.MatchAllQuery{}} 用于查询所有 SearchRequest *search.Request *pkg.CommonPage }
func NewElasticSearchPage ¶
func NewElasticSearchPage(es *database.Es, index string, pageNum, pageSize int) *ElasticSearchPage
func (*ElasticSearchPage) Paginate ¶
func (page *ElasticSearchPage) Paginate() error
Paginate 普通数据数据分页
type GormPage ¶
type GormPage struct { Db *gorm.DB // QueryFunc 查询函数 返回值为 *gorm.DB 类型 用于链式调用 gorm 的查询方法 // 例如: db.Model(&model).Where("id = ?", id) 传入的 model 为 result 的指针 用于接收查询结果 // 例如: db.Model(&model).Where("id = ?", id).Find(&model) QueryFunc func(*gorm.DB) *gorm.DB *pkg.CommonPage }
func NewGormPage ¶
type NativeSqlPage ¶
type NativeSqlPage struct { Db *gorm.DB // CountSQL 查询总数sql 例如: select count(*) from table where id = ? // QuerySQL 查询数据sql 例如: select * from table where id = ? CountSQL, QuerySQL string // CountArgs 查询总数参数 // QueryArgs 查询数据参数 CountArgs, QueryArgs []any *pkg.CommonPage }
func NewNativeSqlPage ¶
func NewNativeSqlPage(db *gorm.DB, pageNum, pageSize int, orderBy ...string) *NativeSqlPage
func (*NativeSqlPage) Paginate ¶
func (page *NativeSqlPage) Paginate() error
Click to show internal directories.
Click to hide internal directories.