zinc

package
v0.0.0-...-8be1489 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HitItem

type HitItem struct {
	Index     string    `json:"_index"`
	Type      string    `json:"_type"`
	ID        string    `json:"_id"`
	Score     float64   `json:"_score"`
	Timestamp time.Time `json:"@timestamp"`
	Source    any       `json:"_source"`
}

type HitsResultT

type HitsResultT struct {
	Total    *HitsResultTotalT `json:"total"`
	MaxScore float64           `json:"max_score"`
	Hits     []*HitItem        `json:"hits"`
}

type HitsResultTotalT

type HitsResultTotalT struct {
	Value int64 `json:"value"`
}

type QueryResultT

type QueryResultT struct {
	Took     int          `json:"took"`
	TimedOut bool         `json:"timed_out"`
	Hits     *HitsResultT `json:"hits"`
}

type ZincClient

type ZincClient struct {
	*ZincClientConfig
}

func NewClient

func NewClient(conf *conf.ZincSettingS) *ZincClient

NewClient 获取ZincClient新实例

func (*ZincClient) ApiQuery

func (c *ZincClient) ApiQuery(indexName string, q any) (*QueryResultT, error)

func (*ZincClient) BulkPushDoc

func (c *ZincClient) BulkPushDoc(docs []map[string]any) (bool, error)

批量新增文档

func (*ZincClient) CreateIndex

func (c *ZincClient) CreateIndex(name string, p *ZincIndexProperty) bool

创建索引

func (*ZincClient) DelDoc

func (c *ZincClient) DelDoc(indexName, id string) error

func (*ZincClient) EsQuery

func (c *ZincClient) EsQuery(indexName string, q any) (*QueryResultT, error)

func (*ZincClient) ExistIndex

func (c *ZincClient) ExistIndex(name string) bool

检查索引是否存在

func (*ZincClient) PutDoc

func (c *ZincClient) PutDoc(name string, id int64, doc any) (bool, error)

新增/更新文档

type ZincClientConfig

type ZincClientConfig struct {
	ZincHost     string
	ZincUser     string
	ZincPassword string
}

type ZincIndex

type ZincIndex struct {
	Name        string             `json:"name"`
	StorageType string             `json:"storage_type"`
	Mappings    *ZincIndexMappings `json:"mappings"`
}

type ZincIndexMappings

type ZincIndexMappings struct {
	Properties *ZincIndexProperty `json:"properties"`
}

type ZincIndexProperty

type ZincIndexProperty map[string]*ZincIndexPropertyT

type ZincIndexPropertyT

type ZincIndexPropertyT struct {
	Type           string `json:"type"`
	Index          bool   `json:"index"`
	Store          bool   `json:"store"`
	Sortable       bool   `json:"sortable"`
	Aggregatable   bool   `json:"aggregatable"`
	Highlightable  bool   `json:"highlightable"`
	Analyzer       string `json:"analyzer"`
	SearchAnalyzer string `json:"search_analyzer"`
	Format         string `json:"format"`
}

Jump to

Keyboard shortcuts

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