goeso

package
v1.2.29 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

go es 难用 :(

  • 基于官方 github.com/elastic/go-elasticsearch/v8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoEs

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

func New

func New(conf elasticsearch.Config) (cli *GoEs, err error)

func (*GoEs) Client

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

func (*GoEs) DeleteIndex

func (cli *GoEs) DeleteIndex(indexes []string) (*esapi.Response, error)

删除 - 根据IDS - Deleting an index

func (*GoEs) DocBatchCreate

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

文档 - 批量添加

func (*GoEs) DocBatchDelete

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

文档 - 批量删除

func (*GoEs) DocCreate

func (cli *GoEs) DocCreate(index, docId string, document interface{}) (*esapi.Response, error)

文档 - 添加 index: 索引 docId: 唯一标识 body: json or struct

func (*GoEs) DocDelete

func (cli *GoEs) DocDelete(index, id string) (*esapi.Response, error)

文档 - 删除 - 根据ID - Deleting documents

func (*GoEs) DocDeleteBy

func (cli *GoEs) DocDeleteBy(index string, query string) (*esapi.Response, error)

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

func (*GoEs) DocExists

func (cli *GoEs) DocExists(index, id string) (bool, error)

文档 - 查询文档 - 根据ID

func (*GoEs) DocGet

func (cli *GoEs) DocGet(index, id string, m interface{}) (bool, error)

文档 - 查询文档 - 根据ID

func (*GoEs) DocMultiGet

func (cli *GoEs) DocMultiGet(index string, ids []string, p *Pagination) (*search.Response, error)

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

func (*GoEs) DocSearch

func (cli *GoEs) DocSearch(index string, query types.Query, p *Pagination) (*search.Response, error)

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

func (*GoEs) DocSearchAll

func (cli *GoEs) DocSearchAll(index string, p *Pagination) (*search.Response, error)

query := `{ "query": { "match_all": {} } }`

func (*GoEs) DocSearchBoolQuery

func (cli *GoEs) DocSearchBoolQuery(terms map[string]interface{}) types.Query

func (*GoEs) DocSearchExistsQuery

func (cli *GoEs) DocSearchExistsQuery(field string) types.Query

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

func (*GoEs) DocSearchMatchQuery

func (cli *GoEs) DocSearchMatchQuery(field string, value string) types.Query

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

func (*GoEs) DocSearchScriptQuery

func (cli *GoEs) DocSearchScriptQuery(script types.Script) types.Query

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

func (*GoEs) DocSearchTermQuery

func (cli *GoEs) DocSearchTermQuery(field string, value any) types.Query

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

func (*GoEs) DocSearchTermsQuery

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

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

func (*GoEs) DocUpdate

func (cli *GoEs) DocUpdate(index, docId string, document interface{}) (*esapi.Response, error)

Updating documents client.Update("my_index", "id", strings.NewReader(`{doc: { language: "Go" }}`))

func (*GoEs) TypeClient

func (cli *GoEs) TypeClient() *elasticsearch.TypedClient

type Pagination

type Pagination struct {
	Sort   string // 排序字段 "example --> published_at:desc "
	Offset int
	Limit  int // default 1000
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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