goes

package
v1.2.170 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-es

目前:v7
https://github.com/olivere/elastic

官方:v7 v8
https://github.com/elastic/go-elasticsearch

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelClient added in v1.2.108

func DelClient(names ...string)

func Init

func Init(conf Config, options ...elastic.ClientOptionFunc) (err error)

可以多次调用初始化多个实例

Types

type BoolQueryAction

type BoolQueryAction string
var (
	BoolQueryMust    BoolQueryAction = "must"
	BoolQueryFilter  BoolQueryAction = "filter"
	BoolQueryShould  BoolQueryAction = "should"
	BoolQueryMustNot BoolQueryAction = "must_not"
)

type Config

type Config struct {
	Name      string `json:"name,optional"  yaml:"Name"`
	Addr      string `json:"addr,optional"  yaml:"Addr"`
	User      string `json:"user,optional"  yaml:"User"`
	Password  string `json:"password,optional"  yaml:"Password"`
	EnableLog bool   `json:"enableLog,optional"  yaml:"EnableLog"`
}

type GoEs added in v1.2.142

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

func Default added in v1.2.83

func Default() *GoEs

func GetClient added in v1.2.83

func GetClient(names ...string) *GoEs

func New

func New(conf Config, options ...elastic.ClientOptionFunc) (cli *GoEs, err error)

func (*GoEs) Client added in v1.2.142

func (cli *GoEs) Client() *elastic.Client

func (*GoEs) DocArrayAppendValue added in v1.2.142

func (cli *GoEs) DocArrayAppendValue(field string, value interface{}) *elastic.Script

3. 数组追加元素

func (*GoEs) DocArrayAppendValues added in v1.2.142

func (cli *GoEs) DocArrayAppendValues(field string, value []interface{}) *elastic.Script

4. 数组追加多个元素

func (*GoEs) DocArrayDelField added in v1.2.142

func (cli *GoEs) DocArrayDelField(field string, value interface{}) *elastic.Script

1. 数组删除元素

func (*GoEs) DocArrayDelFields added in v1.2.142

func (cli *GoEs) DocArrayDelFields(field string, value []interface{}) *elastic.Script

2. 数组删除多个元素

func (*GoEs) DocArrayUpdateValue added in v1.2.142

func (cli *GoEs) DocArrayUpdateValue(field string, old, new interface{}) *elastic.Script

5. 数组修改元素

func (*GoEs) DocBatchCreate added in v1.2.142

func (cli *GoEs) DocBatchCreate(index string, data map[string]interface{}) (resp *elastic.BulkResponse, err error)

文档 - 批量添加

func (*GoEs) DocBatchDelete added in v1.2.142

func (cli *GoEs) DocBatchDelete(index string, ids []string) (total int64, err error)

文档 - 批量删除

func (*GoEs) DocBatchUpdate added in v1.2.142

func (cli *GoEs) DocBatchUpdate(index string, ids []string, docs []interface{}) (err error)

文档 - 批量修改

func (*GoEs) DocBatchUpset added in v1.2.142

func (cli *GoEs) DocBatchUpset(index string, ids []string, docs []interface{}) (err error)

文档 - 批量修改 - 不存在就插入

func (*GoEs) DocCount added in v1.2.142

func (cli *GoEs) DocCount(index string, query elastic.Query) (int64, error)

文档 - 查询文档数量

func (*GoEs) DocCreate added in v1.2.142

func (cli *GoEs) DocCreate(index, id string, body interface{}) (*elastic.IndexResponse, error)

文档 - 添加 index: 索引 id: 唯一标识 body: json格式的数据

func (*GoEs) DocDelete added in v1.2.142

func (cli *GoEs) DocDelete(index, id string) (*elastic.IndexResponse, error)

文档 - 删除 - 根据ID

func (*GoEs) DocDeleteBy added in v1.2.142

func (cli *GoEs) DocDeleteBy(index string, query elastic.Query) (total int64, err error)

文档 - 删除 - 根据条件 即时没有符合条件的文档,也不会报404错误

func (*GoEs) DocGet added in v1.2.142

func (cli *GoEs) DocGet(index, id string, m interface{}) (resp *elastic.GetResult, err error)

文档 - 查询文档 - 根据ID

func (*GoEs) DocMultiGet added in v1.2.142

func (cli *GoEs) DocMultiGet(index string, ids []string, m interface{}) (resp *elastic.MgetResponse, err error)

文档 - 查询文档 - 根据ID集合

func (*GoEs) DocSearch added in v1.2.142

func (cli *GoEs) DocSearch(index string, query elastic.Query, p *Pagination) (resp *elastic.SearchResult, err error)

文档 - 搜索文档 - 根据条件

func (*GoEs) DocSearchBoolQuery added in v1.2.142

func (cli *GoEs) DocSearchBoolQuery(action BoolQueryAction, queries ...elastic.Query) *elastic.BoolQuery

文档 - 搜索条件 - bool 组合查找 must 条件必须要满足,并将对分数起作用 filter 条件必须要满足,但又不同于 must 子句,在 filter context 中执行,这意味着忽略评分,并考虑使用缓存。效率会高于 must should 条件应该满足。可以通过 minimum_should_match 参数指定应该满足的条件个数。如果 bool 查询包含 should 子句,并且没有 must 和 filter 子句,则默认值为 1,否则默认值为 0 must_not 条件必须不能满足。在 filter context 中执行,这意味着评分被忽略,并考虑使用缓存。因为评分被忽略,所以会返回所有 0 分的文档

func (*GoEs) DocSearchExistsQuery added in v1.2.142

func (cli *GoEs) DocSearchExistsQuery(field string) *elastic.ExistsQuery

文档 - 搜索条件 - 判断某个字段是否存在

func (*GoEs) DocSearchMatchQuery added in v1.2.142

func (cli *GoEs) DocSearchMatchQuery(field string, value interface{}) *elastic.MatchQuery

文档 - 搜索条件 - 匹配查找,单字段搜索(匹配分词结果)

func (*GoEs) DocSearchRangeQuery added in v1.2.142

func (cli *GoEs) DocSearchRangeQuery(field string, from, to interface{}) *elastic.RangeQuery

文档 - 搜索条件 - 范围查找

func (*GoEs) DocSearchScriptQuery added in v1.2.142

func (cli *GoEs) DocSearchScriptQuery(script *elastic.Script) *elastic.ScriptQuery

文档 - 搜索条件 - 脚本查询

func (*GoEs) DocSearchTermQuery added in v1.2.142

func (cli *GoEs) DocSearchTermQuery(field string, value interface{}) *elastic.TermQuery

文档 - 搜索条件 - 精确匹配单个字段

func (*GoEs) DocSearchTermsQuery added in v1.2.142

func (cli *GoEs) DocSearchTermsQuery(field string, values []interface{}) *elastic.TermsQuery

文档 - 搜索条件 - 精确匹配多个字段

func (*GoEs) DocUpdate added in v1.2.142

func (cli *GoEs) DocUpdate(index, id string, body interface{}) (response *elastic.UpdateResponse, err error)

文档 - 修改

func (*GoEs) DocUpdateBy added in v1.2.142

func (cli *GoEs) DocUpdateBy(index string, query elastic.Query, script *elastic.Script) (total int64, err error)

文档 - 修改 - 根据条件

func (*GoEs) DocUpset added in v1.2.142

func (cli *GoEs) DocUpset(index, id string, body interface{}) (response *elastic.UpdateResponse, err error)

文档 - 修改 - 不存在就插入

func (*GoEs) IndexAlias added in v1.2.142

func (cli *GoEs) IndexAlias(index, aliasName string) (*elastic.AliasResult, error)

索引 - 别名 - 添加

func (*GoEs) IndexAliasRemove added in v1.2.142

func (cli *GoEs) IndexAliasRemove(index, aliasName string) (*elastic.AliasResult, error)

索引 - 别名 - 删除

func (*GoEs) IndexCreate added in v1.2.142

func (cli *GoEs) IndexCreate(index, body string) (err error)

索引 - 创建

func (*GoEs) IndexDelete added in v1.2.142

func (cli *GoEs) IndexDelete(index string) (err error)

索引 - 删除

func (*GoEs) IndexExists added in v1.2.142

func (cli *GoEs) IndexExists(index string) (bool, error)

索引 - 是否存在

func (*GoEs) IndexGet added in v1.2.142

func (cli *GoEs) IndexGet(index string) (*elastic.IndicesGetResponse, error)

索引 - 查询 - 文档结构、索引设置、data

func (*GoEs) IndexMapping added in v1.2.142

func (cli *GoEs) IndexMapping(index string) (map[string]interface{}, error)

索引 - 查看 - 文档结构

func (*GoEs) IndexNames added in v1.2.142

func (cli *GoEs) IndexNames() ([]string, error)

索引 - 所有索引名称

func (*GoEs) IndexSettings added in v1.2.142

func (cli *GoEs) IndexSettings(index string) (map[string]*elastic.IndicesGetSettingsResponse, error)

索引 - 查看 - 索引设置

func (*GoEs) IndexUpdateMapping added in v1.2.142

func (cli *GoEs) IndexUpdateMapping(index, body string) (*elastic.PutMappingResponse, error)

索引 - 修改 - 文档结构

func (*GoEs) IndexUpdateSettings added in v1.2.142

func (cli *GoEs) IndexUpdateSettings(index, body string) (*elastic.IndicesPutSettingsResponse, error)

索引 - 修改 - 索引设置

type Pagination

type Pagination struct {
	Sort   string // 排序字段
	Order  bool   // true=升序 false=降序
	Offset int
	Limit  int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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