Documentation
¶
Overview ¶
Package templates contains wrappers for helping with creating index and component templates.
Index ¶
- type ComponentTemplate
- type ComponentTemplateOption
- type IndexTemplate
- type IndexTemplateOption
- func AsDatastream(value bool) IndexTemplateOption
- func WithComponentTemplates(names ...string) IndexTemplateOption
- func WithIndexPatterns(patterns ...string) IndexTemplateOption
- func WithIndexTemplateMetadata(metadata types.Metadata) IndexTemplateOption
- func WithPriority(pri int64) IndexTemplateOption
- type Mappings
- type MappingsOption
- type Option
- type Properties
- type PropertiesOption
- func WithBinaryMapping(fieldname string) PropertiesOption
- func WithBooleanMapping(fieldname string) PropertiesOption
- func WithDatetimeMapping(fieldname string) PropertiesOption
- func WithFlattenedMapping(fieldname string) PropertiesOption
- func WithInt64Mapping(fieldname string) PropertiesOption
- func WithKeywordMapping(fieldname string) PropertiesOption
- func WithObjectMapping(fieldname string, options ...PropertiesOption) PropertiesOption
- func WithSemanticTextMapping(fieldname string, settings *types.SemanticTextProperty) PropertiesOption
- func WithTextMapping(fieldname string, settings *types.TextProperty) PropertiesOption
- type Settings
- type SettingsOption
- type Template
- type TemplateOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComponentTemplate ¶
type ComponentTemplate struct {
*putcomponenttemplate.Request
Name string
}
ComponentTemplate represents a component template, a template that can be used within an index template.
func NewComponentTemplate ¶
func NewComponentTemplate( name string, templateSettings *Template, options ...ComponentTemplateOption, ) *ComponentTemplate
NewComponentTemplate creates a component template with the given name and template options.
func (*ComponentTemplate) Put ¶
func (t *ComponentTemplate) Put(ctx context.Context, api *elasticsearch.TypedClient) error
Put will send a request to create the component template in the cluster.
type ComponentTemplateOption ¶
type ComponentTemplateOption Option[*ComponentTemplate]
ComponentTemplateOption is a functional option to apply to a component template.
func WithComponentTemplateMetadata ¶
func WithComponentTemplateMetadata(metadata types.Metadata) ComponentTemplateOption
WithComponentTemplateMetadata sets the given metadata in the component template.
type IndexTemplate ¶
type IndexTemplate struct {
*putindextemplate.Request
Name string
}
IndexTemplate represents an index template.
func NewIndexTemplate ¶
func NewIndexTemplate(name string, options ...IndexTemplateOption) *IndexTemplate
NewIndexTemplate creates an index template with the given name and template options.
func (*IndexTemplate) Put ¶
func (t *IndexTemplate) Put(ctx context.Context, api *elasticsearch.TypedClient) error
Put will send a request to create the index template in the cluster.
type IndexTemplateOption ¶
type IndexTemplateOption Option[*IndexTemplate]
IndexTemplateOption is a functional option to apply to an index template.
func AsDatastream ¶
func AsDatastream(value bool) IndexTemplateOption
AsDatastream option will ensure the indicies using this template will be treated as a datastream.
func WithComponentTemplates ¶
func WithComponentTemplates(names ...string) IndexTemplateOption
WithComponentTemplates option sets the index template to be composed from the given component template names.
func WithIndexPatterns ¶
func WithIndexPatterns(patterns ...string) IndexTemplateOption
WithIndexPatterns option sets the index template to match and apply to the given index patterns.
func WithIndexTemplateMetadata ¶
func WithIndexTemplateMetadata(metadata types.Metadata) IndexTemplateOption
WithIndexTemplateMetadata option sets the given metadata in the index template.
func WithPriority ¶
func WithPriority(pri int64) IndexTemplateOption
WithPriority option defines the priority for this index template.
type Mappings ¶
type Mappings struct {
*types.TypeMapping
}
Mappings represents the mappings for a template.
func NewMappings ¶
func NewMappings(options ...MappingsOption) *Mappings
NewMappings creates new mappings with the given options.
type MappingsOption ¶
MappingsOption is a functional option to apply a mappings setting.
func WithDynamicProperties ¶
func WithDynamicProperties(value bool) MappingsOption
WithDynamicProperties option sets whether dynamic properties are allowed.
func WithMetadata ¶
func WithMetadata(metadata types.Metadata) MappingsOption
WithMetadata option sets metadata for the properties mapping.
func WithProperties ¶
func WithProperties(options ...PropertiesOption) MappingsOption
WithProperties option sets field properties in the mapping.
type Option ¶
type Option[T any] func(T)
Option is a reusable generic function for applying options to a type.
type Properties ¶
Properties represents the mapping of field properties.
func NewProperties ¶
func NewProperties(options ...PropertiesOption) Properties
NewProperties creates a set of field mappings with the given options.
type PropertiesOption ¶
type PropertiesOption Option[Properties]
PropertiesOption is a functional option to set the properties for a field.
func WithBinaryMapping ¶
func WithBinaryMapping(fieldname string) PropertiesOption
WithBinaryMapping option creates a new field with a binary mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/binary
func WithBooleanMapping ¶
func WithBooleanMapping(fieldname string) PropertiesOption
WithBooleanMapping option creates a new field with a boolean mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/boolean
func WithDatetimeMapping ¶
func WithDatetimeMapping(fieldname string) PropertiesOption
WithDatetimeMapping option creates a new field with a datetime mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/date_nanos
func WithFlattenedMapping ¶
func WithFlattenedMapping(fieldname string) PropertiesOption
WithFlattenedMapping option creates a new field with a flattened mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/flattened
func WithInt64Mapping ¶ added in v0.24.0
func WithInt64Mapping(fieldname string) PropertiesOption
WithInt64Mapping option creates a new numeric field with a int64 (long) mapping.
func WithKeywordMapping ¶
func WithKeywordMapping(fieldname string) PropertiesOption
WithKeywordMapping option creates a new field with a keyword mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/keyword
func WithObjectMapping ¶
func WithObjectMapping(fieldname string, options ...PropertiesOption) PropertiesOption
WithObjectMapping option creates a new field with a object mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/object
func WithSemanticTextMapping ¶ added in v0.33.0
func WithSemanticTextMapping(fieldname string, settings *types.SemanticTextProperty) PropertiesOption
WithSemanticTextMapping option creates a new field with a semantic_text mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/semantic-text
func WithTextMapping ¶
func WithTextMapping(fieldname string, settings *types.TextProperty) PropertiesOption
WithTextMapping option creates a new field with a text mapping.
https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/text
type Settings ¶
type Settings struct {
*types.IndexSettings
}
Settings represents the settings for a template.
func NewSettings ¶
func NewSettings(options ...SettingsOption) *Settings
NewSettings creates new settings with the given options.
type SettingsOption ¶
SettingsOption is a functional option to apply a template setting.
func WithAnalysis ¶
func WithAnalysis(analysis types.IndexSettingsAnalysis) SettingsOption
WithAnalysis option will apply the provided analysis settings.
func WithLifecycle ¶
func WithLifecycle(name, rolloverAlias string) SettingsOption
WithLifecycle option will ensure the template applies the given lifecycle policy name to indices.
func WithMode ¶
func WithMode(mode string) SettingsOption
WithMode option will apply the given index mode to the template.
type Template ¶
type Template struct {
types.IndexTemplateMapping
}
Template represents an index or component template with settings, mappings, aliases, etc.
func NewTemplate ¶
func NewTemplate(options ...TemplateOption) *Template
NewTemplate creates a new template with the given options.
type TemplateOption ¶
TemplateOption is a functional option to apply to a template.
func WithAlias ¶
func WithAlias(name string, settings *types.Alias) TemplateOption
WithAlias option assigns an alias with the given name and settings to the template.
func WithTemplateMapping ¶
func WithTemplateMapping(options ...MappingsOption) TemplateOption
WithTemplateMapping option applies the given mapping options to the template.
func WithTemplateSettings ¶
func WithTemplateSettings(options ...SettingsOption) TemplateOption
WithTemplateSettings option applies the given settings options to the template.