logdb

package
v0.0.0-...-39a21f2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StandardAnalyzer   = "standard"
	SimpleAnalyzer     = "simple"
	WhitespaceAnalyzer = "whitespace"
	StopAnalyzer       = "stop"
	AnsjAnalyzer       = "index_ansj"
	DicAnajAnalyzer    = "dic_ansj"
	SearchAnsjAnalyzer = "search_ansj"
	ToAnsjAnalyzer     = "to_ansj"
	UserAnsjAnalyzer   = "user_ansj"
	KeyWordAnalyzer    = "keyword"
	PathAnalyzer       = "path"
)
View Source
const (
	TypeString   = "string"
	TypeLong     = "long"
	TypeFloat    = "float"
	TypeBoolean  = "boolean"
	TypeDate     = "date"
	TypeGeoPoint = "geo_point"
	TypeIP       = "ip"
	TypeObject   = "object"
)
View Source
const (
	PartialQuerySearchTypeA int = iota //混合模式
	PartialQuerySearchTypeQ            //searching模式
	PartialQuerySearchTypeH            //直方图模式
)

Variables

Functions

func NewConfig

func NewConfig() *config.Config

func NewFullText

func NewFullText(analyzer string, enabled bool) fullText

func SchemaToDSL

func SchemaToDSL(schemas []RepoSchemaEntry, indent string) (dsl string)

SchemaToDSL 会把schema信息转换为格式化的dsl字符串,其中indent是格式化的占位符,一般是"\t"或者2个空格。

Types

type CreateRepoDSLInput

type CreateRepoDSLInput struct {
	PandoraToken
	RepoName  string
	Region    string `json:"region"`
	Retention string `json:"retention"`
	DSL       string `json:"dsl"`
}

type CreateRepoInput

type CreateRepoInput struct {
	PandoraToken
	RepoName     string
	Region       string            `json:"region"`
	Retention    string            `json:"retention"`
	Schema       []RepoSchemaEntry `json:"schema"`
	PrimaryField string            `json:"primaryField"`
	FullText     fullText          `json:"fullText"`
}

func (*CreateRepoInput) Validate

func (r *CreateRepoInput) Validate() (err error)

type DeleteRepoInput

type DeleteRepoInput struct {
	PandoraToken
	RepoName string
}

type GetRepoConfigInput

type GetRepoConfigInput struct {
	PandoraToken
	RepoName string
}

type GetRepoConfigOutput

type GetRepoConfigOutput struct {
	TimeFieldName string `json:"timeFieldName"`
}

type GetRepoInput

type GetRepoInput struct {
	PandoraToken
	RepoName string
}

type GetRepoOutput

type GetRepoOutput struct {
	Region       string            `json:"region"`
	Retention    string            `json:"retention"`
	Schema       []RepoSchemaEntry `json:"schema"`
	PrimaryField string            `json:"primaryField"`
	CreateTime   string            `json:"createTime"`
	UpdateTime   string            `json:"updateTime"`
	FullText     fullText          `json:"fullText"`
}

type Highlight

type Highlight struct {
	PreTags           []string               `json:"pre_tags"`
	PostTags          []string               `json:"post_tags"`
	Fields            map[string]interface{} `json:"fields"`
	RequireFieldMatch bool                   `json:"require_field_match"`
	FragmentSize      int                    `json:"fragment_size"`
}

func (*Highlight) Validate

func (h *Highlight) Validate() error

type ListReposInput

type ListReposInput struct {
	PandoraToken
}

type ListReposOutput

type ListReposOutput struct {
	Repos []RepoDesc `json:"repos"`
}

type Log

type Log map[string]interface{}

type LogHistogramDesc

type LogHistogramDesc struct {
	Key   int64 `json:"key"`
	Count int64 `json:"count"`
}

type Logdb

type Logdb struct {
	Config     *config.Config
	HTTPClient *http.Client
}

func NewClient

func NewClient(c *config.Config) (p *Logdb, err error)

func (*Logdb) CreateRepo

func (c *Logdb) CreateRepo(input *CreateRepoInput) (err error)

func (*Logdb) CreateRepoFromDSL

func (c *Logdb) CreateRepoFromDSL(input *CreateRepoDSLInput) (err error)

func (*Logdb) DeleteRepo

func (c *Logdb) DeleteRepo(input *DeleteRepoInput) (err error)

func (*Logdb) GetRepo

func (c *Logdb) GetRepo(input *GetRepoInput) (output *GetRepoOutput, err error)

func (*Logdb) GetRepoConfig

func (c *Logdb) GetRepoConfig(input *GetRepoConfigInput) (output *GetRepoConfigOutput, err error)

func (*Logdb) GetSampleDataSchema

func (c *Logdb) GetSampleDataSchema(input *SchemaRefInput) (output *SchemaRefOut, err error)

输入JSON样例数据,输出对应的LOGDB Schema

func (*Logdb) ListRepos

func (c *Logdb) ListRepos(input *ListReposInput) (output *ListReposOutput, err error)

func (*Logdb) MakeToken

func (c *Logdb) MakeToken(desc *base.TokenDesc) (string, error)

func (*Logdb) NewOperation

func (c *Logdb) NewOperation(opName string, args ...interface{}) *request.Operation

func (*Logdb) PartialQuery

func (c *Logdb) PartialQuery(input *PartialQueryInput) (output *PartialQueryOutput, err error)

func (*Logdb) PutRepoConfig

func (c *Logdb) PutRepoConfig(input *PutRepoConfigInput) (err error)

func (*Logdb) QueryAnalysisLog

func (c *Logdb) QueryAnalysisLog(jobId string) (output *QueryAnalysisLogOutput, err error)

func (*Logdb) QueryAnalysisLogJob

func (c *Logdb) QueryAnalysisLogJob(input *QueryAnalysisLogInput) (jobId string, err error)

func (*Logdb) QueryHistogramLog

func (c *Logdb) QueryHistogramLog(input *QueryHistogramLogInput) (output *QueryHistogramLogOutput, err error)

func (*Logdb) QueryLog

func (c *Logdb) QueryLog(input *QueryLogInput) (output *QueryLogOutput, err error)

func (*Logdb) QueryScroll

func (c *Logdb) QueryScroll(input *QueryScrollInput) (output *QueryLogOutput, err error)

func (*Logdb) QuerySearchLog

func (c *Logdb) QuerySearchLog(jobId string) (output *QuerySearchLogOutput, err error)

func (*Logdb) QuerySearchLogJob

func (c *Logdb) QuerySearchLogJob(input *QuerySearchLogInput) (jobId string, err error)

func (*Logdb) SendLog

func (c *Logdb) SendLog(input *SendLogInput) (output *SendLogOutput, err error)

func (*Logdb) UpdateRepo

func (c *Logdb) UpdateRepo(input *UpdateRepoInput) (err error)

type LogdbAPI

type LogdbAPI interface {
	CreateRepo(*CreateRepoInput) error

	GetRepo(*GetRepoInput) (*GetRepoOutput, error)

	ListRepos(*ListReposInput) (*ListReposOutput, error)

	DeleteRepo(*DeleteRepoInput) error

	UpdateRepo(*UpdateRepoInput) error

	SendLog(*SendLogInput) (*SendLogOutput, error)

	QueryLog(*QueryLogInput) (*QueryLogOutput, error)

	QuerySearchLogJob(*QuerySearchLogInput) (string, error)

	QuerySearchLog(string) (*QuerySearchLogOutput, error)

	QueryAnalysisLogJob(*QueryAnalysisLogInput) (string, error)

	QueryAnalysisLog(string) (*QueryAnalysisLogOutput, error)

	QueryScroll(*QueryScrollInput) (*QueryLogOutput, error)

	QueryHistogramLog(*QueryHistogramLogInput) (*QueryHistogramLogOutput, error)

	PutRepoConfig(*PutRepoConfigInput) error

	GetRepoConfig(*GetRepoConfigInput) (*GetRepoConfigOutput, error)

	MakeToken(*base.TokenDesc) (string, error)

	PartialQuery(input *PartialQueryInput) (output *PartialQueryOutput, err error)

	GetSampleDataSchema(input *SchemaRefInput) (output *SchemaRefOut, err error)
}

func New

func New(c *config.Config) (LogdbAPI, error)

type LogdbErrBuilder

type LogdbErrBuilder struct{}

func (LogdbErrBuilder) Build

func (e LogdbErrBuilder) Build(msg, text, reqId string, code int) error

type Logs

type Logs []Log

func (Logs) Buf

func (ls Logs) Buf() (buf []byte, err error)

type PartialQueryInput

type PartialQueryInput struct {
	PandoraToken
	RepoName  string `json:"-"`
	StartTime int64  `json:"startTime"`
	EndTime   int64  `json:"endTime"`
	Highlight struct {
		PostTag string `json:"post_tag"`
		PreTag  string `json:"pre_tag"`
	} `json:"highlight"`
	QueryString string `json:"query_string"`
	SearchType  int    `json:"searchType"`
	Size        int    `json:"size"`
	Sort        string `json:"sort"`
}

func (*PartialQueryInput) Buf

func (partialQueryInput *PartialQueryInput) Buf() (buf []byte, err error)

type PartialQueryOutput

type PartialQueryOutput struct {
	Buckets []struct {
		Count int `json:"count"`
		Key   int `json:"key"`
	} `json:"buckets"`
	Hits           []map[string]interface{} `json:"hits"`
	PartialSuccess bool                     `json:"partialSuccess"`
	Process        float64                  `json:"process"`
	Took           int                      `json:"took"`
	Total          int                      `json:"total"`
}

type PutRepoConfigInput

type PutRepoConfigInput struct {
	PandoraToken
	RepoName      string
	TimeFieldName string `json:"timeFieldName"`
}

func (*PutRepoConfigInput) Validate

func (r *PutRepoConfigInput) Validate() (err error)

type QueryAnalysisLogHit

type QueryAnalysisLogHit struct {
	Type  string                 `json:"_type,omitempty"`
	Id    string                 `json:"_id,omitempty"`
	Score float32                `json:"_score,omitempty"`
	Data  map[string]interface{} `json:"_source,omitempty"`
}

type QueryAnalysisLogInput

type QueryAnalysisLogInput struct {
	PandoraToken
	Start    time.Time
	End      time.Time
	RepoName string
	Query    string
	Sort     string
	From     int
	Size     int
	Scroll   string
	Fields   string
}

func (*QueryAnalysisLogInput) Buf

func (input *QueryAnalysisLogInput) Buf() (buf []byte, err error)

type QueryAnalysisLogOutput

type QueryAnalysisLogOutput struct {
	Took           int                   `json:"took,omitempty"`
	Process        float32               `json:"process,omitempty"`
	Total          int                   `json:"total"`
	PartialSuccess bool                  `json:"partialSuccess"`
	Hits           []QueryAnalysisLogHit `json:"hits"`
}

type QueryHistogramLogInput

type QueryHistogramLogInput struct {
	PandoraToken
	RepoName string
	Query    string
	Field    string
	From     int64
	To       int64
}

type QueryHistogramLogOutput

type QueryHistogramLogOutput struct {
	Total          int                `json:"total"`
	PartialSuccess bool               `json:"partialSuccess"`
	Buckets        []LogHistogramDesc `json:"buckets"`
}

type QueryLogInput

type QueryLogInput struct {
	PandoraToken
	RepoName  string
	Query     string
	Sort      string
	From      int
	Size      int
	Scroll    string
	Fields    string
	Highlight *Highlight
}

type QueryLogOutput

type QueryLogOutput struct {
	ScrollId       string                   `json:"scroll_id,omitempty"`
	Total          int                      `json:"total"`
	PartialSuccess bool                     `json:"partialSuccess"`
	Data           []map[string]interface{} `json:"data"`
}

type QueryScrollInput

type QueryScrollInput struct {
	PandoraToken
	RepoName string `json:"-"`
	ScrollId string `json:"scroll_id"`
	Scroll   string `json:"scroll"`
}

func (*QueryScrollInput) Buf

func (input *QueryScrollInput) Buf() (buf []byte, err error)

type QuerySearchLogHit

type QuerySearchLogHit struct {
	IsFullText bool   `json:"isFullText,omitempty"`
	Id         string `json:"id,omitempty"`
	// Timestamp  time.Time              `json:"timestamp,omitempty"`
	Data map[string]interface{} `json:"source,omitempty"`
}

type QuerySearchLogInput

type QuerySearchLogInput struct {
	PandoraToken
	Start    time.Time
	End      time.Time
	RepoName string
	Query    string
	Sort     string
}

func (*QuerySearchLogInput) Buf

func (input *QuerySearchLogInput) Buf() (buf []byte, err error)

type QuerySearchLogOutput

type QuerySearchLogOutput struct {
	Took           int                 `json:"took,omitempty"`
	Process        float32             `json:"process,omitempty"`
	Total          int                 `json:"total"`
	PartialSuccess bool                `json:"partial_success"`
	Hits           []QuerySearchLogHit `json:"hits"`
}

type RepoDesc

type RepoDesc struct {
	RepoName     string   `json:"name"`
	Region       string   `json:"region"`
	PrimaryField string   `json:"primaryField"`
	Retention    string   `json:"retention"`
	CreateTime   string   `json:"createTime"`
	UpdateTime   string   `json:"updateTime"`
	FullText     fullText `json:"fullText"`
}

type RepoSchemaEntry

type RepoSchemaEntry struct {
	Key       string                 `json:"key"`
	ValueType string                 `json:"valtype"`
	Analyzer  string                 `json:"analyzer,omitempty"` //替代SearchWay
	Primary   bool                   `json:"primary,omitempty"`  //默认值是false
	Schemas   []RepoSchemaEntry      `json:"nested,omitempty"`
	Options   map[string]interface{} `json:"options,omitempty"` // 对于一些特殊的类型,比如IP或者geo_point会有一些特殊的属性。
}

func DSLtoSchema

func DSLtoSchema(dsl string) (schemas []RepoSchemaEntry, err error)

DSLtoSchema 是将DSL字符串转化为schema

func (RepoSchemaEntry) String

func (e RepoSchemaEntry) String() string

func (*RepoSchemaEntry) Validate

func (e *RepoSchemaEntry) Validate() (err error)

type SchemaRefInput

type SchemaRefInput struct {
	PandoraToken
	SampleData map[string]interface{} `json:"sample_data"`
}

func (SchemaRefInput) Buf

func (srf SchemaRefInput) Buf() (buf []byte, err error)

type SchemaRefOut

type SchemaRefOut []RepoSchemaEntry

type SendLogInput

type SendLogInput struct {
	PandoraToken
	RepoName       string `json:"-"`
	OmitInvalidLog bool   `json:"-"`
	Logs           Logs
}

type SendLogOutput

type SendLogOutput struct {
	Success int `json:"success"`
	Failed  int `json:"failed"`
	Total   int `json:"total"`
}

type UpdateRepoInput

type UpdateRepoInput struct {
	PandoraToken
	RepoName  string
	Retention string            `json:"retention"`
	Schema    []RepoSchemaEntry `json:"schema"`
}

func (*UpdateRepoInput) Validate

func (r *UpdateRepoInput) Validate() (err error)

Jump to

Keyboard shortcuts

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