elastic

package module
v0.0.0-...-b586f71 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 12 Imported by: 0

README

belastic

Documentation

Index

Constants

View Source
const (
	OptIndex = iota
	OptCreate
	OptUpdate
	OptDelete
)
View Source
const (
	TypeBinary  = `binary`
	TypeBoolean = `boolean`
	TypeByte    = `byte`
	TypeShort   = `short`
	TypeInteger = `integer`
	TypeLong    = `long`
	TypeUlong   = `unsigned_long`
	TypeFloat   = `float`
	TypeDouble  = `double`
	TypeKeyword = `keyword`
	TypeText    = `text`
	TypeDate    = `date`
	TypeIp      = `ip`
	TypeVersion = `version`
)
View Source
const (
	FormatDate                 = `yyyy-MM-dd`
	FormatDateTime             = `yyyy-MM-dd HH:mm:ss`
	FormatUnixTime             = `epoch_second`
	FormatTimestampSecond      = FormatUnixTime
	FormatTimestampMilliSecond = `epoch_millis`
)
View Source
const (
	And = ` AND `
	Or  = ` OR `
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkDoc

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

func CreateDoc

func CreateDoc(index string, fieldValue base.JsonParam) BulkDoc

func DeleteDoc

func DeleteDoc(index, id string) BulkDoc

func IndexDoc

func IndexDoc(index, id string, fieldValue base.JsonParam) BulkDoc

func UpdateDoc

func UpdateDoc(index, id string, fieldValue base.JsonParam) BulkDoc

func (*BulkDoc) Build

func (bi *BulkDoc) Build() string

type Condition

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

func AndCondition

func AndCondition(items ...Operator) Condition

func OrCondition

func OrCondition(items ...Operator) Condition

func (Condition) Build

func (c Condition) Build() string

type Connection

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

func New

func New(opt Option) *Connection

func (*Connection) Bulk

func (c *Connection) Bulk(timeout time.Duration, param string) (resp *Response, err error)

Bulk link: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

func (*Connection) Delete

func (c *Connection) Delete(timeout time.Duration, path string, params string) (*Response, error)

func (*Connection) DocsBulk

func (c *Connection) DocsBulk(timeout time.Duration, items ...BulkDoc) (resp *Response, err error)

func (*Connection) DocsMGet

func (c *Connection) DocsMGet(timeout time.Duration, index string, idList ...string) (rows *results.DocumentsResult, err error)

DocsMGet link: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html

func (*Connection) DocsMSet

func (c *Connection) DocsMSet(timeout time.Duration, index string, rows ...base.JsonParam) (resp *Response, err error)

func (*Connection) DocsUpdateWithVersion

func (c *Connection) DocsUpdateWithVersion(timeout time.Duration, index string, id string, version int64, fullDoc base.JsonParam) (*results.IndexResult, error)

DocsUpdateWithVersion link: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

func (*Connection) Get

func (c *Connection) Get(timeout time.Duration, path string, params string) (*Response, error)

func (*Connection) IndexCreate

func (c *Connection) IndexCreate(timeout time.Duration, index string, settings *Settings, mappings *Mappings) (ok bool, err error)

func (*Connection) IndexDelete

func (c *Connection) IndexDelete(timeout time.Duration, index string) (ok bool, err error)

func (*Connection) MappingsAlter

func (c *Connection) MappingsAlter(timeout time.Duration, index string, mappings *Mappings) (ok bool, err error)

MappingsAlter link: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

func (*Connection) Post

func (c *Connection) Post(timeout time.Duration, path string, params string) (*Response, error)

func (*Connection) Put

func (c *Connection) Put(timeout time.Duration, path string, params string) (*Response, error)

func (*Connection) SetMaxResultWindow

func (c *Connection) SetMaxResultWindow(timeout time.Duration, index string, value int64) (ok bool, err error)

func (*Connection) SettingsAlter

func (c *Connection) SettingsAlter(timeout time.Duration, index string, settings base.JsonParam) (ok bool, err error)

SettingsAlter link: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html

func (*Connection) SqlTranslate

func (c *Connection) SqlTranslate(timeout time.Duration, sql string, limit int) (*Response, error)

SqlTranslate link: https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html

type Field

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

func Gt

func Gt(field string, value string) Field

func Gte

func Gte(field string, value string) Field

func Lt

func Lt(field string, value string) Field

func Lte

func Lte(field string, value string) Field

func NotNil

func NotNil(field string) Field

func Term

func Term(field string, value string) Field

func Terms

func Terms(field string, values ...string) Field

func (Field) Build

func (f Field) Build() string

type Mappings

type Mappings struct {
	Properties map[string]*Property `json:"properties"`
}

func (*Mappings) Add

func (m *Mappings) Add(properties ...*Property) *Mappings

func (*Mappings) Marshal

func (m *Mappings) Marshal() []byte

type Operator

type Operator interface {
	Build() string
}

type Option

type Option struct {
	BaseUrl               string `json:"baseUrl" yaml:"baseUrl"`
	UserName              string `json:"userName" yaml:"userName"`
	Password              string `json:"password" yaml:"password"`
	DialTimeoutSecond     int64  `json:"dialTimeoutSecond" yaml:"dialTimeoutSecond"`
	KeepaliveSecond       int64  `json:"keepaliveSecond" yaml:"keepaliveSecond"`
	IdleConnTimeoutSecond int64  `json:"idleConnTimeoutSecond" yaml:"idleConnTimeoutSecond"`
	MaxIdleConns          int    `json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxIdleConnsPerHost   int    `json:"maxIdleConnsPerHost" yaml:"maxIdleConnsPerHost"`
	MaxConnsPerHost       int    `json:"maxConnsPerHost" yaml:"maxConnsPerHost"`
}

type Order

type Order []OrderBy

type OrderBy

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

func Asc

func Asc(field string) OrderBy

func Desc

func Desc(field string) OrderBy

type Property

type Property struct {
	Type   string `json:"type"`
	Format string `json:"format,omitempty"`
	// contains filtered or unexported fields
}

func NewProperty

func NewProperty(fieldName, fieldType string) *Property

func (*Property) FieldName

func (p *Property) FieldName() string

func (*Property) WithFormat

func (p *Property) WithFormat(format string) *Property

type Query

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

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

func (*Query) After

func (q *Query) After(sortItems ...interface{}) *Query

func (*Query) Build

func (q *Query) Build() string

func (*Query) From

func (q *Query) From(index string) *Query

func (*Query) Limit

func (q *Query) Limit(size int) *Query

func (*Query) Offset

func (q *Query) Offset(offset int64) *Query

func (*Query) OrderBy

func (q *Query) OrderBy(order ...OrderBy) *Query

func (*Query) Search

func (q *Query) Search(timeout time.Duration, conn *Connection) (result *results.SearchResult, err error)

func (*Query) SearchRows

func (q *Query) SearchRows(timeout time.Duration, conn *Connection) (result *results.RowsResult, err error)

func (*Query) Select

func (q *Query) Select(fields ...string) *Query

func (*Query) Where

func (q *Query) Where(condition Condition) *Query

func (*Query) WhereString

func (q *Query) WhereString(where string) *Query

type Response

type Response struct {
	Status int    `json:"status"`
	Body   []byte `json:"body"`
}

func (*Response) Error

func (r *Response) Error() (err error)

func (*Response) Is

func (r *Response) Is(status int) bool

func (*Response) IsOk

func (r *Response) IsOk() bool

func (*Response) UnmarshalBulkResult

func (r *Response) UnmarshalBulkResult() (*results.BulkResult, error)

func (*Response) UnmarshalDocumentResult

func (r *Response) UnmarshalDocumentResult() (*results.DocumentResult, error)

func (*Response) UnmarshalDocumentsResult

func (r *Response) UnmarshalDocumentsResult() (*results.DocumentsResult, error)

func (*Response) UnmarshalIndexResult

func (r *Response) UnmarshalIndexResult() (*results.IndexResult, error)

func (*Response) UnmarshalSearchResult

func (r *Response) UnmarshalSearchResult() (*results.SearchResult, error)

func (*Response) UnmarshalSqlSearchResult

func (r *Response) UnmarshalSqlSearchResult() (*results.SqlSearchResult, error)

type Settings

type Settings struct {
	NumberOfShards   int `json:"number_of_shards"`
	NumberOfReplicas int `json:"number_of_replicas,omitempty"`
}

func (*Settings) Marshal

func (s *Settings) Marshal() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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