Documentation ¶
Index ¶
- type ElasticClient
- type ElasticContent
- type ElasticRepository
- func (e *ElasticRepository) Add(id string, entity interface{}) (res *elastic.IndexResponse, err error)
- func (e *ElasticRepository) AddMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)
- func (e *ElasticRepository) GetById(id string, entity interface{}) error
- func (e *ElasticRepository) Query(query elastic.Query) (result *elastic.SearchResult, err error)
- func (e *ElasticRepository) Remove(ids ...string) (res *elastic.BulkResponse, err error)
- func (e *ElasticRepository) Search(query elastic.Query) (entity []interface{}, totalCount int64, err error)
- func (e *ElasticRepository) SearchPage(query elastic.Query, pageIndex, pageSize int) (entity []interface{}, totalCount int64, err error)
- func (e *ElasticRepository) Set(id string, doc map[string]interface{}) (res *elastic.UpdateResponse, err error)
- func (e *ElasticRepository) SetMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)
- type IElasticRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElasticClient ¶
type ElasticClient struct {
// contains filtered or unexported fields
}
Elastic 客户端
func GetElasticClient ¶
func GetElasticClient(config map[string]string) (*ElasticClient, error)
type ElasticContent ¶
type ElasticContent struct { *ElasticClient // contains filtered or unexported fields }
集合上下文
func DataBaseMapping ¶
func DataBaseMapping(config map[string]string) (*ElasticContent, error)
添加映射 @client 连接对象
func (*ElasticContent) GetElasticRepository ¶ added in v1.4.2
func (elasti *ElasticContent) GetElasticRepository(entity interface{}) IElasticRepository
获取集合仓储 entity 结构体
type ElasticRepository ¶
type ElasticRepository struct {
// contains filtered or unexported fields
}
Elastic 仓储
func (*ElasticRepository) Add ¶ added in v1.6.0
func (e *ElasticRepository) Add(id string, entity interface{}) (res *elastic.IndexResponse, err error)
插入单个 id id值 entity 结构体
func (*ElasticRepository) AddMany ¶ added in v1.6.0
func (e *ElasticRepository) AddMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)
插入多个 entityMap【id值】结构体
func (*ElasticRepository) GetById ¶
func (e *ElasticRepository) GetById(id string, entity interface{}) error
查询单个 id id值 entity 查询的结果
func (*ElasticRepository) Query ¶
func (e *ElasticRepository) Query(query elastic.Query) (result *elastic.SearchResult, err error)
查询 query 查询条件 返回 搜索结果不处理
func (*ElasticRepository) Remove ¶ added in v1.6.0
func (e *ElasticRepository) Remove(ids ...string) (res *elastic.BulkResponse, err error)
删除 ids id值
func (*ElasticRepository) Search ¶
func (e *ElasticRepository) Search(query elastic.Query) (entity []interface{}, totalCount int64, err error)
搜索 query 查询条件 搜索返回具体结果
func (*ElasticRepository) SearchPage ¶
func (e *ElasticRepository) SearchPage(query elastic.Query, pageIndex, pageSize int) (entity []interface{}, totalCount int64, err error)
搜索结果分页显示((pageSize-1)*pageIndex <= 10000,大于则获取不到内容) query 查询条件 pageIndex 当前页,从1开始 pageSize 每页多少条 entity 当前页详细数据 totalCount 页总数
func (*ElasticRepository) Set ¶ added in v1.6.0
func (e *ElasticRepository) Set(id string, doc map[string]interface{}) (res *elastic.UpdateResponse, err error)
更新 id 文档id doc 更新内容
func (*ElasticRepository) SetMany ¶ added in v1.6.0
func (e *ElasticRepository) SetMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)
更新多个 entityMap【id值】结构体
type IElasticRepository ¶
type IElasticRepository interface { // 插入单个 // id id值 // entity 结构体 Add(id string, entity interface{}) (res *elastic.IndexResponse, err error) // 插入多个 // entityMap【id值】结构体 AddMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error) // 删除 // ids id值 Remove(id ...string) (*elastic.BulkResponse, error) //更新 //id 文档id //doc 更新内容 Set(id string, doc map[string]interface{}) (res *elastic.UpdateResponse, err error) // 更新多个 // entityMap【id值】结构体 SetMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error) //查询单个 // id id值 // entity 查询的结果 GetById(id string, result interface{}) error //查询 //query 查询条件 //返回 搜索结果不处理 Query(query elastic.Query) (result *elastic.SearchResult, err error) // 搜索 // query 查询条件 // 搜索返回具体结果 Search(query elastic.Query) (entity []interface{}, totalCount int64, err error) // 搜索结果分页显示((pageSize-1)*pageIndex <= 10000,大于则获取不到内容) //query 查询条件 //pageIndex 当前页,从1开始 //pageSize 每页多少条 //entity 当前页详细数据 //totalCount 页总数 SearchPage(query elastic.Query, pageIndex, pageSize int) (entity []interface{}, totalCount int64, err error) }
搜索引擎仓储接口
Click to show internal directories.
Click to hide internal directories.