ElasticSearch

package
v1.6.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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
}

ElasticClient 客户端

func GetElasticClient

func GetElasticClient(config map[string]string) (*ElasticClient, error)

GetElasticClient 获取es客户端对象

type ElasticContent

type ElasticContent struct {
	*ElasticClient
	// contains filtered or unexported fields
}

ElasticContent 集合上下文

func DataBaseMapping

func DataBaseMapping(mappingName string, configFn func(mappingName string) map[string]string, entitysFn func() []interface{}) (*ElasticContent, error)

DataBaseMapping 添加映射 @client 连接对象

func (*ElasticContent) GetElasticRepository added in v1.4.2

func (elasti *ElasticContent) GetElasticRepository(entity interface{}) (IElasticRepository, bool)

GetElasticRepository 获取集合仓储 entity 结构体

type ElasticRepository

type ElasticRepository struct {
	// contains filtered or unexported fields
}

ElasticRepository 仓储

func (*ElasticRepository) Add added in v1.6.0

func (e *ElasticRepository) Add(id string, entity interface{}) (res *elastic.IndexResponse, err error)

Add 插入单个 id id值 entity 结构体

func (*ElasticRepository) AddMany added in v1.6.0

func (e *ElasticRepository) AddMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)

AddMany 插入多个 entityMap【id值】结构体

func (*ElasticRepository) GetById

func (e *ElasticRepository) GetById(id string, entity interface{}) error

GetById 查询单个 id id值 entity 查询的结果

func (*ElasticRepository) Query

func (e *ElasticRepository) Query(query elastic.Query) (result *elastic.SearchResult, err error)

Query 查询 query 查询条件 返回 搜索结果不处理

func (*ElasticRepository) Remove added in v1.6.0

func (e *ElasticRepository) Remove(ids ...string) (res *elastic.BulkResponse, err error)

Remove 删除 ids id值

func (*ElasticRepository) Search

func (e *ElasticRepository) Search(query elastic.Query) (entity []interface{}, totalCount int64, err error)

Search 搜索 query 查询条件 entityTyp 结果集转换类型对应 entity []interface{} 中 interface{} 类型 搜索返回具体结果

func (*ElasticRepository) SearchPage

func (e *ElasticRepository) SearchPage(query elastic.Query, pageIndex, pageSize int) (entity []interface{}, totalCount int64, err error)

SearchPage 搜索结果分页显示((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)

Set 更新 id 文档id doc 更新内容

func (*ElasticRepository) SetMany added in v1.6.0

func (e *ElasticRepository) SetMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)

SetMany 更新多个 entityMap【id值】结构体

type IElasticRepository

type IElasticRepository interface {

	//Add 插入单个
	// id id值
	// entity  结构体
	Add(id string, entity interface{}) (res *elastic.IndexResponse, err error)

	//AddMany 插入多个
	// entityMap【id值】结构体
	AddMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)

	//Remove 删除
	// ids id值
	Remove(id ...string) (*elastic.BulkResponse, error)

	//Set 更新
	//id     文档id
	//doc    更新内容
	Set(id string, doc map[string]interface{}) (res *elastic.UpdateResponse, err error)

	//SetMany 更新多个
	// entityMap【id值】结构体
	SetMany(entityMap map[string]interface{}) (res *elastic.BulkResponse, err error)

	//GetById 查询单个
	// id         id值
	// entity      查询的结果
	GetById(id string, result interface{}) error

	//Query 查询
	//query  查询条件
	//返回 搜索结果不处理
	Query(query elastic.Query) (result *elastic.SearchResult, err error)

	//Search 搜索
	// query  查询条件
	// 搜索返回具体结果
	Search(query elastic.Query) (entity []interface{}, totalCount int64, err error)

	//SearchPage 搜索结果分页显示((pageSize-1)*pageIndex <= 10000,大于则获取不到内容)
	//query      查询条件
	//pageIndex  当前页,从1开始
	//pageSize   每页多少条
	//entity     当前页详细数据
	//totalCount 页总数
	SearchPage(query elastic.Query, pageIndex, pageSize int) (entity []interface{}, totalCount int64, err error)
}

IElasticRepository 搜索引擎仓储接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL