Documentation ¶
Index ¶
- Constants
- type ElasticConf
- type ElasticsearchClient
- func (ec *ElasticsearchClient) CheckIndex(ctx *gin.Context, indexName string) (bool, error)
- func (ec *ElasticsearchClient) CreateIndex(ctx *gin.Context, indexName string, mapping *types.TypeMapping, ...) error
- func (ec *ElasticsearchClient) DeleteIndex(ctx *gin.Context, indexName string) error
- func (ec *ElasticsearchClient) DocumentDelete(ctx *gin.Context, indexName string, query *types.Query) error
- func (ec *ElasticsearchClient) DocumentInsert(ctx *gin.Context, indexName string, docs []any) (err error)
- func (ec *ElasticsearchClient) Search(ctx *gin.Context, indexName string, query *search.Request) (*search.Response, error)
Constants ¶
View Source
const ( ES_LOG_MAX_REQ_LEN = "ES_LOG_MAX_REQ_LEN" ES_LOG_MAX_RESP_LEN = "ES_LOG_MAX_RESP_LEN" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElasticConf ¶
type ElasticsearchClient ¶
type ElasticsearchClient struct { Client *elasticsearch.TypedClient MaxReqBodyLen int // response body 最大长度展示,0表示采用默认的10240,-1表示不打印。指定长度的时候需注意,返回的json可能被截断 MaxRespBodyLen int }
func InitESClient ¶
func InitESClient(conf ElasticConf) (*ElasticsearchClient, error)
func (*ElasticsearchClient) CheckIndex ¶
CheckIndex 判断索引是否存在
func (*ElasticsearchClient) CreateIndex ¶
func (ec *ElasticsearchClient) CreateIndex(ctx *gin.Context, indexName string, mapping *types.TypeMapping, setting *types.IndexSettings) error
CreateIndex 根据提供的 mapping 创建索引
func (*ElasticsearchClient) DeleteIndex ¶
func (ec *ElasticsearchClient) DeleteIndex(ctx *gin.Context, indexName string) error
删除索引
func (*ElasticsearchClient) DocumentDelete ¶
func (ec *ElasticsearchClient) DocumentDelete(ctx *gin.Context, indexName string, query *types.Query) error
BulkDelete 批量删除文档
func (*ElasticsearchClient) DocumentInsert ¶
func (ec *ElasticsearchClient) DocumentInsert(ctx *gin.Context, indexName string, docs []any) (err error)
BulkInsert 批量插入数据,批量限制为 3000 条
Click to show internal directories.
Click to hide internal directories.