template

package
v6.0.0-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfig for index template
	DefaultConfig = TemplateConfig{
		Enabled: true,
		Fields:  "fields.yml",
	}
)

Functions

This section is empty.

Types

type ESClient

type ESClient interface {
	LoadJSON(path string, json map[string]interface{}) ([]byte, error)
	Request(method, path string, pipeline string, params map[string]string, body interface{}) (int, []byte, error)
	GetVersion() string
}

TemplateLoader is a subset of the Elasticsearch client API capable of loading the template.

type Field

type Field struct {
	Name           string `config:"name"`
	Type           string `config:"type"`
	Description    string `config:"description"`
	Format         string `config:"format"`
	ScalingFactor  int    `config:"scaling_factor"`
	Fields         Fields `config:"fields"`
	MultiFields    Fields `config:"multi_fields"`
	ObjectType     string `config:"object_type"`
	Enabled        *bool  `config:"enabled"`
	Analyzer       string `config:"analyzer"`
	SearchAnalyzer string `config:"search_analyzer"`
	Norms          bool   `config:"norms"`
	// contains filtered or unexported fields
}

type Fields

type Fields []Field

func (Fields) HasKey

func (f Fields) HasKey(key string) bool

HasKey checks if inside fields the given key exists The key can be in the form of a.b.c and it will check if the nested field exist In case the key is `a` and there is a value `a.b` false is return as it only returns true if it's a leave node

type Loader

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

func NewLoader

func NewLoader(cfg *common.Config, client ESClient, beatInfo beat.Info) (*Loader, error)

func (*Loader) CheckTemplate

func (l *Loader) CheckTemplate(templateName string) bool

CheckTemplate checks if a given template already exist. It returns true if and only if Elasticsearch returns with HTTP status code 200.

func (*Loader) Load

func (l *Loader) Load() error

Load checks if the index mapping template should be loaded In case the template is not already loaded or overwriting is enabled, the template is written to index

func (*Loader) LoadTemplate

func (l *Loader) LoadTemplate(templateName string, template map[string]interface{}) error

LoadTemplate loads a template into Elasticsearch overwriting the existing template if it exists. If you wish to not overwrite an existing template then use CheckTemplate prior to calling this method.

type Template

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

func New

func New(beatVersion string, beatName string, esVersion string, config TemplateConfig) (*Template, error)

New creates a new template instance

func (*Template) GetName

func (t *Template) GetName() string

GetName returns the name of the template

func (*Template) GetPattern

func (t *Template) GetPattern() string

GetPattern returns the pattern of the template

func (*Template) Load

func (t *Template) Load(file string) (common.MapStr, error)

Load the given input and generates the input based on it

type TemplateConfig

type TemplateConfig struct {
	Enabled   bool             `config:"enabled"`
	Name      string           `config:"name"`
	Pattern   string           `config:"pattern"`
	Fields    string           `config:"fields"`
	Overwrite bool             `config:"overwrite"`
	Settings  TemplateSettings `config:"settings"`
}

type TemplateSettings

type TemplateSettings struct {
	Index  map[string]interface{} `config:"index"`
	Source map[string]interface{} `config:"_source"`
}

Jump to

Keyboard shortcuts

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