Documentation
¶
Overview ¶
Update field mappings. Add new fields to an existing data stream or index. You can also use this API to change the search settings of existing fields and add new properties to existing object fields. For data streams, these changes are applied to all backing indices by default.
**Add multi-fields to an existing field**
Multi-fields let you index the same field in different ways. You can use this API to update the fields mapping parameter and enable multi-fields for an existing field. WARNING: If an index (or data stream) contains documents when you add a multi-field, those documents will not have values for the new multi-field. You can populate the new multi-field with the update by query API.
**Change supported mapping parameters for an existing field**
The documentation for each mapping parameter indicates whether you can update it for an existing field using this API. For example, you can use the update mapping API to update the `ignore_above` parameter.
**Change the mapping of an existing field**
Except for supported mapping parameters, you can't change the mapping or field type of an existing field. Changing an existing field could invalidate data that's already indexed.
If you need to change the mapping of a field in a data stream's backing indices, refer to documentation about modifying data streams. If you need to change the mapping of a field in other indices, create a new index with the correct mapping and reindex your data into that index.
**Rename a field**
Renaming a field would invalidate data already indexed under the old field name. Instead, add an alias field to create an alternate field name.
Index ¶
- Variables
- type NewPutMapping
- type PutMapping
- func (r *PutMapping) AddProperty(key string, value types.PropertyVariant) *PutMapping
- func (r *PutMapping) AllowNoIndices(allownoindices bool) *PutMapping
- func (r *PutMapping) DateDetection(datedetection bool) *PutMapping
- func (r PutMapping) Do(providedCtx context.Context) (*Response, error)
- func (r *PutMapping) Dynamic(dynamic dynamicmapping.DynamicMapping) *PutMapping
- func (r *PutMapping) DynamicDateFormats(dynamicdateformats ...string) *PutMapping
- func (r *PutMapping) DynamicTemplates(dynamictemplates []map[string]types.DynamicTemplate) *PutMapping
- func (r *PutMapping) ErrorTrace(errortrace bool) *PutMapping
- func (r *PutMapping) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *PutMapping
- func (r *PutMapping) FieldNames_(fieldnames_ types.FieldNamesFieldVariant) *PutMapping
- func (r *PutMapping) FilterPath(filterpaths ...string) *PutMapping
- func (r *PutMapping) Header(key, value string) *PutMapping
- func (r *PutMapping) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *PutMapping) Human(human bool) *PutMapping
- func (r *PutMapping) IgnoreUnavailable(ignoreunavailable bool) *PutMapping
- func (r *PutMapping) MasterTimeout(duration string) *PutMapping
- func (r *PutMapping) Meta_(metadata types.MetadataVariant) *PutMapping
- func (r *PutMapping) NumericDetection(numericdetection bool) *PutMapping
- func (r PutMapping) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *PutMapping) Pretty(pretty bool) *PutMapping
- func (r *PutMapping) Properties(properties map[string]types.Property) *PutMapping
- func (r *PutMapping) Raw(raw io.Reader) *PutMapping
- func (r *PutMapping) Request(req *Request) *PutMapping
- func (r *PutMapping) Routing_(routing_ types.RoutingFieldVariant) *PutMapping
- func (r *PutMapping) Runtime(runtimefields types.RuntimeFieldsVariant) *PutMapping
- func (r *PutMapping) Source_(source_ types.SourceFieldVariant) *PutMapping
- func (r *PutMapping) Timeout(duration string) *PutMapping
- func (r *PutMapping) WriteIndexOnly(writeindexonly bool) *PutMapping
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")
ErrBuildPath is returned in case of missing parameters within the build of the request.
Functions ¶
This section is empty.
Types ¶
type NewPutMapping ¶
type NewPutMapping func(index string) *PutMapping
NewPutMapping type alias for index.
func NewPutMappingFunc ¶
func NewPutMappingFunc(tp elastictransport.Interface) NewPutMapping
NewPutMappingFunc returns a new instance of PutMapping with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.
type PutMapping ¶
type PutMapping struct {
// contains filtered or unexported fields
}
func New ¶
func New(tp elastictransport.Interface) *PutMapping
Update field mappings. Add new fields to an existing data stream or index. You can also use this API to change the search settings of existing fields and add new properties to existing object fields. For data streams, these changes are applied to all backing indices by default.
**Add multi-fields to an existing field**
Multi-fields let you index the same field in different ways. You can use this API to update the fields mapping parameter and enable multi-fields for an existing field. WARNING: If an index (or data stream) contains documents when you add a multi-field, those documents will not have values for the new multi-field. You can populate the new multi-field with the update by query API.
**Change supported mapping parameters for an existing field**
The documentation for each mapping parameter indicates whether you can update it for an existing field using this API. For example, you can use the update mapping API to update the `ignore_above` parameter.
**Change the mapping of an existing field**
Except for supported mapping parameters, you can't change the mapping or field type of an existing field. Changing an existing field could invalidate data that's already indexed.
If you need to change the mapping of a field in a data stream's backing indices, refer to documentation about modifying data streams. If you need to change the mapping of a field in other indices, create a new index with the correct mapping and reindex your data into that index.
**Rename a field**
Renaming a field would invalidate data already indexed under the old field name. Instead, add an alias field to create an alternate field name.
https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-indices-put-mapping
func (*PutMapping) AddProperty ¶
func (r *PutMapping) AddProperty(key string, value types.PropertyVariant) *PutMapping
func (*PutMapping) AllowNoIndices ¶
func (r *PutMapping) AllowNoIndices(allownoindices bool) *PutMapping
AllowNoIndices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices. This behavior applies even if the request targets other open indices. API name: allow_no_indices
func (*PutMapping) DateDetection ¶
func (r *PutMapping) DateDetection(datedetection bool) *PutMapping
Controls whether dynamic date detection is enabled. API name: date_detection
func (PutMapping) Do ¶
func (r PutMapping) Do(providedCtx context.Context) (*Response, error)
Do runs the request through the transport, handle the response and returns a putmapping.Response
func (*PutMapping) Dynamic ¶
func (r *PutMapping) Dynamic(dynamic dynamicmapping.DynamicMapping) *PutMapping
Controls whether new fields are added dynamically. API name: dynamic
func (*PutMapping) DynamicDateFormats ¶
func (r *PutMapping) DynamicDateFormats(dynamicdateformats ...string) *PutMapping
If date detection is enabled then new string fields are checked against 'dynamic_date_formats' and if the value matches then a new date field is added instead of string. API name: dynamic_date_formats
func (*PutMapping) DynamicTemplates ¶
func (r *PutMapping) DynamicTemplates(dynamictemplates []map[string]types.DynamicTemplate) *PutMapping
Specify dynamic templates for the mapping. API name: dynamic_templates
func (*PutMapping) ErrorTrace ¶
func (r *PutMapping) ErrorTrace(errortrace bool) *PutMapping
ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace
func (*PutMapping) ExpandWildcards ¶
func (r *PutMapping) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *PutMapping
ExpandWildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. API name: expand_wildcards
func (*PutMapping) FieldNames_ ¶
func (r *PutMapping) FieldNames_(fieldnames_ types.FieldNamesFieldVariant) *PutMapping
Control whether field names are enabled for the index. API name: _field_names
func (*PutMapping) FilterPath ¶
func (r *PutMapping) FilterPath(filterpaths ...string) *PutMapping
FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path
func (*PutMapping) Header ¶
func (r *PutMapping) Header(key, value string) *PutMapping
Header set a key, value pair in the PutMapping headers map.
func (*PutMapping) HttpRequest ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*PutMapping) Human ¶
func (r *PutMapping) Human(human bool) *PutMapping
Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human
func (*PutMapping) IgnoreUnavailable ¶
func (r *PutMapping) IgnoreUnavailable(ignoreunavailable bool) *PutMapping
IgnoreUnavailable If `false`, the request returns an error if it targets a missing or closed index. API name: ignore_unavailable
func (*PutMapping) MasterTimeout ¶
func (r *PutMapping) MasterTimeout(duration string) *PutMapping
MasterTimeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. API name: master_timeout
func (*PutMapping) Meta_ ¶
func (r *PutMapping) Meta_(metadata types.MetadataVariant) *PutMapping
A mapping type can have custom meta data associated with it. These are not used at all by Elasticsearch, but can be used to store application-specific metadata. API name: _meta
func (*PutMapping) NumericDetection ¶
func (r *PutMapping) NumericDetection(numericdetection bool) *PutMapping
Automatically map strings into numeric data types for all fields. API name: numeric_detection
func (PutMapping) Perform ¶
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*PutMapping) Pretty ¶
func (r *PutMapping) Pretty(pretty bool) *PutMapping
Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty
func (*PutMapping) Properties ¶
func (r *PutMapping) Properties(properties map[string]types.Property) *PutMapping
Mapping for a field. For new fields, this mapping can include:
- Field name - Field data type - Mapping parameters API name: properties
func (*PutMapping) Raw ¶
func (r *PutMapping) Raw(raw io.Reader) *PutMapping
Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.
func (*PutMapping) Request ¶
func (r *PutMapping) Request(req *Request) *PutMapping
Request allows to set the request property with the appropriate payload.
func (*PutMapping) Routing_ ¶
func (r *PutMapping) Routing_(routing_ types.RoutingFieldVariant) *PutMapping
Enable making a routing value required on indexed documents. API name: _routing
func (*PutMapping) Runtime ¶
func (r *PutMapping) Runtime(runtimefields types.RuntimeFieldsVariant) *PutMapping
Mapping of runtime fields for the index. API name: runtime
func (*PutMapping) Source_ ¶
func (r *PutMapping) Source_(source_ types.SourceFieldVariant) *PutMapping
Control whether the _source field is enabled on the index. API name: _source
func (*PutMapping) Timeout ¶
func (r *PutMapping) Timeout(duration string) *PutMapping
Timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. API name: timeout
func (*PutMapping) WriteIndexOnly ¶
func (r *PutMapping) WriteIndexOnly(writeindexonly bool) *PutMapping
WriteIndexOnly If `true`, the mappings are applied only to the current write index for the target. API name: write_index_only
type Request ¶
type Request struct { // DateDetection Controls whether dynamic date detection is enabled. DateDetection *bool `json:"date_detection,omitempty"` // Dynamic Controls whether new fields are added dynamically. Dynamic *dynamicmapping.DynamicMapping `json:"dynamic,omitempty"` // DynamicDateFormats If date detection is enabled then new string fields are checked // against 'dynamic_date_formats' and if the value matches then // a new date field is added instead of string. DynamicDateFormats []string `json:"dynamic_date_formats,omitempty"` // DynamicTemplates Specify dynamic templates for the mapping. DynamicTemplates []map[string]types.DynamicTemplate `json:"dynamic_templates,omitempty"` // FieldNames_ Control whether field names are enabled for the index. FieldNames_ *types.FieldNamesField `json:"_field_names,omitempty"` // Meta_ A mapping type can have custom meta data associated with it. These are // not used at all by Elasticsearch, but can be used to store // application-specific metadata. Meta_ types.Metadata `json:"_meta,omitempty"` // NumericDetection Automatically map strings into numeric data types for all fields. NumericDetection *bool `json:"numeric_detection,omitempty"` // Properties Mapping for a field. For new fields, this mapping can include: // // - Field name // - Field data type // - Mapping parameters Properties map[string]types.Property `json:"properties,omitempty"` // Routing_ Enable making a routing value required on indexed documents. Routing_ *types.RoutingField `json:"_routing,omitempty"` // Runtime Mapping of runtime fields for the index. Runtime types.RuntimeFields `json:"runtime,omitempty"` // Source_ Control whether the _source field is enabled on the index. Source_ *types.SourceField `json:"_source,omitempty"` }
Request holds the request body struct for the package putmapping
func (*Request) UnmarshalJSON ¶
type Response ¶
type Response struct { // Acknowledged For a successful response, this value is always true. On failure, an // exception is returned instead. Acknowledged bool `json:"acknowledged"` Shards_ *types.ShardStatistics `json:"_shards,omitempty"` }
Response holds the response body struct for the package putmapping