es

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHOULD queryLogic = iota + 1
	MUST
	MUSTNOT
)
View Source
const (
	TERMS queryType = iota + 1
	MATCHPHRASE
	RANGE
	PREFIX
	WILDCARD
)
View Source
const (
	TEXT    esFieldType = "text"
	KEYWORD esFieldType = "keyword"
	DATE    esFieldType = "date"
	LONG    esFieldType = "long"
	INTEGER esFieldType = "integer"
	SHORT   esFieldType = "short"
	DOUBLE  esFieldType = "double"
	FLOAT   esFieldType = "float"
	BOOL    esFieldType = "boolean"
)

Variables

View Source
var G_EsClient *elastic.Client

Functions

func BulkDelete

func BulkDelete(esindex, estype string, ids []string) error

func BulkSaveOrUpdate

func BulkSaveOrUpdate(esindex, estype string, docs []map[string]interface{}) error

func CheckTypeExists

func CheckTypeExists(esindex, estype string) (b bool, err error)

func ClearIndex

func ClearIndex(index string) error

func Count

func Count(paging *Paging, esIndex string, esType string) (int64, error)

func DeleteIndex

func DeleteIndex(index string) error

func GetByID

func GetByID(id string, esIndex string, esType string) (map[string]interface{}, error)

func InitG_EsClient

func InitG_EsClient(hosts []string, username, password string)

func List

func List(paging *Paging, esIndex string, esType string, callback func(message json.RawMessage) (interface{}, error)) ([]interface{}, error)

func NewIndex

func NewIndex(index string, mapping string) (exists bool, err error)

func NewMapping

func NewMapping(mp MappingPayload) string

func PutMapping

func PutMapping(mp MappingPayload) error

func Random

func Random(paging *Paging, esIndex string, esType string) ([]interface{}, error)

func SetupSubTest

func SetupSubTest(index string, t *testing.T) func(t *testing.T)

func Stat

func Stat(paging *Paging, esIndex string, esType string, aggr interface{}) (interface{}, error)

Types

type Base

type Base struct {
	Index string `json:"index"`
	Type  string `json:"type"`
}

func (*Base) GetIndex

func (b *Base) GetIndex() string

func (*Base) GetType

func (b *Base) GetType() string

func (*Base) SetType

func (b *Base) SetType(s string)

type Field

type Field struct {
	Name   string      `json:"name"`
	Type   esFieldType `json:"type"`
	Format string      `json:"format"`
}

type IBase

type IBase interface {
	GetIndex() string
	GetType() string
	SetType(s string)
}

type MappingPayload

type MappingPayload struct {
	Base
	Fields []Field `json:"fields"`
}

type PageResult

type PageResult struct {
	Page        int           `json:"page"` // from 1
	PageSize    int           `json:"page_size"`
	Total       int           `json:"total"`
	Docs        []interface{} `json:"docs"`
	HasNextPage bool          `json:"has_next_page"`
}

func Page

func Page(paging *Paging, esIndex string, esType string) (PageResult, error)

type Paging

type Paging struct {
	StartDate  string      `json:"start_date"`
	EndDate    string      `json:"end_date"`
	DateField  string      `json:"date_field"`
	QueryConds []QueryCond `json:"query_conds"`
	Skip       int         `json:"skip"`
	Limit      int         `json:"limit"`
	Sortby     []Sort      `json:"sortby"`
}

type QueryCond

type QueryCond struct {
	Pair       map[string][]interface{} `json:"pair"`
	QueryLogic queryLogic               `json:"query_logic"`
	QueryType  queryType                `json:"query_type"`
}

type Sort

type Sort struct {
	Field     string
	Ascending bool
}

Jump to

Keyboard shortcuts

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