es

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

golang-es

go使用es的封装
这里用的包是:github.com/olivere/elastic/v7

基本的是增删改查已经完成

后续完善:
查询结果映射到struct或map中
完善分页查询和映射

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ElasticPool = make(map[string]*Elastic)
)

es 缓存池

Functions

This section is empty.

Types

type Elastic

type Elastic struct {
	Client *elastic.Client
	// contains filtered or unexported fields
}

func InitES

func InitES(addr string, port int, user, password, name string) *Elastic

func (*Elastic) CreateIndex

func (self *Elastic) CreateIndex(index string) bool

创建 index

func (*Elastic) CreateIndexAndMapping

func (self *Elastic) CreateIndexAndMapping(index, mapping string) bool

新建索引

func (*Elastic) Del

func (self *Elastic) Del(index, typ, id string) bool

数据删除

func (*Elastic) DelIndex

func (self *Elastic) DelIndex(index string) bool

删除索引

func (*Elastic) JsonMap

func (self *Elastic) JsonMap(index, typ, query string, fields []string, from, size int,
	terms map[string]interface{}, mustNot, filter, sort []map[string]interface{}) map[string]interface{}

func (*Elastic) MultiMatchQueryBestFields

func (self *Elastic) MultiMatchQueryBestFields(index, typ, text string, start, end int, fields ...string) *elastic.SearchResult

多条件参考:https://stackoverflow.com/questions/49942373/golang-elasticsearch-multiple-query-parameters

func (*Elastic) Put

func (self *Elastic) Put(index, typ, id, bodyJson string) bool

存储-string类型

func (*Elastic) PutAny

func (self *Elastic) PutAny(index, typ, id string, body interface{}) bool

存储-任何数据

func (*Elastic) QueryString

func (self *Elastic) QueryString(index, typ, query string, size int) *elastic.SearchResult

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-query-string-query.html

func (*Elastic) QueryStringMap

func (self *Elastic) QueryStringMap(index, typ, query string, start, end int) map[string]interface{}

func (*Elastic) QueryStringRandomSearch

func (self *Elastic) QueryStringRandomSearch(client *elastic.Client, index, typ, query string, size int) *elastic.SearchResult

func (*Elastic) RangeQueryLoginDate

func (self *Elastic) RangeQueryLoginDate(index string, typ string, start, end int) *elastic.SearchResult

func (*Elastic) TermQuery

func (self *Elastic) TermQuery(index, typ string, term *elastic.TermQuery, start, end int) *elastic.SearchResult

func (*Elastic) Update

func (self *Elastic) Update(index, typ, id string, updateMap map[string]interface{}) bool

更新数据

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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