es

package module
v0.0.0-...-6d4b899 Latest Latest
Warning

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

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

Documentation

Overview

Package es Date: 2023/3/24 18:00 Author: Amu Description:

Package es Date: 2023/12/1 15:43 Author: Amu Description:

Package es Date: 2023/3/24 14:30 Author: Amu Description:

Package es Date: 2023/12/1 15:51 Author: Amu Description:

Package es Date: 2023/4/20 17:03 Author: Amu Description:

Package es Date: 2023/3/27 15:50 Author: Amu Description:

Package es Date: 2023/3/30 15:12 Author: Amu Description:

Package es Date: 2023/3/27 19:14 Author: Amu Description: 索引声明周期管理策略

Package es Date: 2023/3/30 12:07 Author: Amu Description: client crud

Package es Date: 2023/12/1 16:04 Author: Amu Description:

Package es Date: 2023/3/27 19:14 Author: Amu Description: 索引模版

Package es Date: 2023/3/28 14:19 Author: Amu Description:

Index

Constants

View Source
const (
	CreateIndexRetry    = 50
	CreatePolicyRetry   = 50
	CreateTemplateRetry = 50
	PolicyFilePrefix    = "policy_"
	PolicyFileSuffix    = ".json"
	TemplateFilePrefix  = "template_"
	TemplateFileSuffix  = ".json"
)

Variables

View Source
var (
	NewMatchQuery             = elastic.NewMatchQuery
	NewTermQuery              = elastic.NewTermQuery
	NewTermsQuery             = elastic.NewTermsQuery
	NewTermsQueryFrom         = elastic.NewTermsQueryFromStrings
	NewBoolQuery              = elastic.NewBoolQuery
	NewRangeQuery             = elastic.NewRangeQuery
	NewNestedQuery            = elastic.NewNestedQuery
	NewMatchAllQuery          = elastic.NewMatchAllQuery
	NewMatchPhraseQuery       = elastic.NewMatchPhraseQuery
	NewMatchPhrasePrefixQuery = elastic.NewMatchPhrasePrefixQuery
	NewRegexpQuery            = elastic.NewRegexpQuery

	NewTermsAggregation     = elastic.NewTermsAggregation
	NewAvgAggregation       = elastic.NewAvgAggregation
	NewDateRangeAggregation = elastic.NewDateRangeAggregation
	NewFilterAggregation    = elastic.NewFilterAggregation
	NewFiltersAggregation   = elastic.NewFiltersAggregation
	NewSumAggregation       = elastic.NewSumAggregation
	NewMaxAggregation       = elastic.NewMaxAggregation
	NewMinAggregation       = elastic.NewMinAggregation
)

Functions

This section is empty.

Types

type Agg

type Agg struct {
	Name string
	Agg  elastic.Aggregation
}

func (*Agg) Action

func (a *Agg) Action(service *elastic.SearchService) *elastic.SearchService

type Attr

type Attr struct {
	Attr    []string // 需要包含或剔除的字段
	Include bool     // 包含还是剔除
}

func (*Attr) Action

func (a *Attr) Action(service *elastic.SearchService) *elastic.SearchService

func (*Attr) ActionScroll

func (a *Attr) ActionScroll(service *elastic.SearchService) *elastic.SearchService

type BulkOption

type BulkOption func(*bulkOption)

func WithBulkActions

func WithBulkActions(actions int) BulkOption

func WithBulkFlushInterval

func WithBulkFlushInterval(interval string) BulkOption

func WithBulkSize

func WithBulkSize(size int) BulkOption

func WithBulkWorkers

func WithBulkWorkers(workers int) BulkOption

type BulkProcessor

type BulkProcessor struct {
	*elastic.BulkProcessor
}

BulkProcessor 增删改批量操作

func NewBulkProcessor

func NewBulkProcessor(client *Client, opts ...BulkOption) (*BulkProcessor, error)

func (*BulkProcessor) Close

func (p *BulkProcessor) Close() error

func (*BulkProcessor) Create

func (p *BulkProcessor) Create(indexName string, doc interface{})

func (*BulkProcessor) Delete

func (p *BulkProcessor) Delete(indexName string, docIDs []string)

func (*BulkProcessor) Flush

func (p *BulkProcessor) Flush() error

func (*BulkProcessor) Start

func (p *BulkProcessor) Start(ctx context.Context) error

func (*BulkProcessor) Stats

func (p *BulkProcessor) Stats() BulkStats

func (*BulkProcessor) Stop

func (p *BulkProcessor) Stop() error

func (*BulkProcessor) Update

func (p *BulkProcessor) Update(indexName string, docID string, doc interface{})

type BulkRequest

type BulkRequest struct {
	Doc    interface{}
	Index  string
	Action string
}

type BulkStats

type BulkStats struct {
	Flushed   int64 // number of times the flush interval has been invoked
	Committed int64 // # of times workers committed bulk requests
	Indexed   int64 // # of requests indexed
	Created   int64 // # of requests that ES reported as creates (201)
	Updated   int64 // # of requests that ES reported as updates
	Deleted   int64 // # of requests that ES reported as deletes
	Succeeded int64 // # of requests that ES reported as successful
	Failed    int64 // # of requests that ES reported as failed
}

type Client

type Client struct {
	*elastic.Client
}

func NewEsClient

func NewEsClient(opts ...ClientOption) (*Client, error)

func (*Client) CountByIndices

func (c *Client) CountByIndices(ctx context.Context, indexNames []string, options ...CountOption) (int64, error)

func (*Client) CreateIndex

func (c *Client) CreateIndex(ctx context.Context, indexName string, indexBody string) (bool, error)

func (*Client) DeleteILMPolicy

func (c *Client) DeleteILMPolicy(ctx context.Context, policyName string) (bool, error)

func (*Client) DeleteIndex

func (c *Client) DeleteIndex(ctx context.Context, indexNames []string) error

func (*Client) DeleteIndexTemplate

func (c *Client) DeleteIndexTemplate(ctx context.Context, templateName string) (bool, error)

func (*Client) Find

func (c *Client) Find(ctx context.Context, bulkModel Model, options ...QueryOption) (*elastic.SearchResult, error)

func (*Client) FindByIndexName

func (c *Client) FindByIndexName(ctx context.Context, indexNames []string, options ...QueryOption) (*elastic.SearchResult, error)

func (*Client) FindByIndexNameScroll

func (c *Client) FindByIndexNameScroll(ctx context.Context, indexNames []string, scrollID string, size int, options ...ScrollQueryOption) (*elastic.SearchResult, error)

func (*Client) FindScroll

func (c *Client) FindScroll(ctx context.Context, bulkModel Model, scrollID string, size int, options ...ScrollQueryOption) (*elastic.SearchResult, error)

func (*Client) GetCountService

func (c *Client) GetCountService(options ...CountOption) *elastic.CountService

func (*Client) GetDeleteService

func (c *Client) GetDeleteService(options ...DeleteOption) *elastic.DeleteService

func (*Client) GetILMPolicy

func (c *Client) GetILMPolicy(ctx context.Context, policyName string) (map[string]interface{}, error)

func (*Client) GetIndexTemplate

func (c *Client) GetIndexTemplate(ctx context.Context, templateName string) (*elastic.IndicesGetIndexTemplateData, error)

func (*Client) GetMappings

func (c *Client) GetMappings(ctx context.Context, indexName string) (map[string]interface{}, error)

func (*Client) GetQueryService

func (c *Client) GetQueryService(options ...QueryOption) *elastic.SearchService

func (*Client) GetScrollQueryService

func (c *Client) GetScrollQueryService(options ...ScrollQueryOption) *elastic.ScrollService

func (*Client) GetSettings

func (c *Client) GetSettings(ctx context.Context, indexName string) (map[string]interface{}, error)

func (*Client) ILMPolicyExists

func (c *Client) ILMPolicyExists(ctx context.Context, policyName string) (bool, error)

func (*Client) IndexExists

func (c *Client) IndexExists(ctx context.Context, indexName string) (bool, error)

func (*Client) IndexStatus

func (c *Client) IndexStatus(ctx context.Context, indexName string) (indices map[string]*elastic.IndexStats, err error)

func (*Client) PutILMPolicy

func (c *Client) PutILMPolicy(ctx context.Context, policyName string, policyBody string) (bool, error)

func (*Client) PutIndexTemplate

func (c *Client) PutIndexTemplate(ctx context.Context, templateName string, templateBody string) (bool, error)

func (*Client) ReadFile

func (c *Client) ReadFile(fileName string) (string, error)

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, indexName string) error

func (*Client) TemplateExists

func (c *Client) TemplateExists(ctx context.Context, templateName string) (bool, error)

type ClientOption

type ClientOption func(option *clientOption)

func WithAddr

func WithAddr(addr string) ClientOption

func WithDebug

func WithDebug(debug bool) ClientOption

func WithHealthcheck

func WithHealthcheck(check bool) ClientOption

func WithPassword

func WithPassword(password string) ClientOption

func WithSniff

func WithSniff(sniff bool) ClientOption

func WithUsername

func WithUsername(username string) ClientOption

type CountOption

type CountOption interface {
	Action(service *elastic.CountService) *elastic.CountService
}

type CountQuery

type CountQuery struct {
	Query elastic.Query
}

func (*CountQuery) Action

func (c *CountQuery) Action(service *elastic.SearchService) *elastic.SearchService

type DeleteOption

type DeleteOption interface {
	Action(service *elastic.DeleteService) *elastic.DeleteService
}

type DeleteQuery

type DeleteQuery struct {
	Query elastic.Query
}

func (*DeleteQuery) Action

func (d *DeleteQuery) Action(service *elastic.SearchService) *elastic.SearchService

type Model

type Model interface {
	GetIndexName() string
	GetId() string
}

type Page

type Page struct {
	Count  int
	Offset int
}

func (*Page) Action

func (p *Page) Action(service *elastic.SearchService) *elastic.SearchService

type QueryOption

type QueryOption interface {
	Action(service *elastic.SearchService) *elastic.SearchService
}

type ScrollQueryOption

type ScrollQueryOption interface {
	ActionScroll(service *elastic.ScrollService) *elastic.ScrollService
}

type Sort

type Sort struct {
	Params [][2]interface{}
}

func (*Sort) Action

func (s *Sort) Action(service *elastic.SearchService) *elastic.SearchService

func (*Sort) ActionScroll

func (s *Sort) ActionScroll(service *elastic.SearchService) *elastic.SearchService

type SortInfo

type SortInfo struct {
	Params []elastic.SortInfo
}

func (*SortInfo) Action

func (si *SortInfo) Action(service *elastic.SearchService) *elastic.SearchService

func (*SortInfo) ActionScroll

func (si *SortInfo) ActionScroll(service *elastic.SearchService) *elastic.SearchService

Jump to

Keyboard shortcuts

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