diff --git a/indices_create.go b/indices_create.go index 4bcd77be..3457fb41 100644 --- a/indices_create.go +++ b/indices_create.go @@ -28,11 +28,12 @@ type IndicesCreateService struct { filterPath []string // list of filters used to reduce the response headers http.Header // custom request-level HTTP headers - index string - timeout string - masterTimeout string - bodyJson interface{} - bodyString string + index string + timeout string + masterTimeout string + includeTypeName *bool + bodyJson interface{} + bodyString string } // NewIndicesCreateService returns a new IndicesCreateService. @@ -98,6 +99,12 @@ func (s *IndicesCreateService) MasterTimeout(masterTimeout string) *IndicesCreat return s } +// IncludeTypeName indicates whether a type should be expected in the body of the mappings. +func (s *IndicesCreateService) IncludeTypeName(includeTypeName bool) *IndicesCreateService { + s.includeTypeName = &includeTypeName + return s +} + // Body specifies the configuration of the index as a string. // It is an alias for BodyString. func (s *IndicesCreateService) Body(body string) *IndicesCreateService { @@ -151,6 +158,9 @@ func (s *IndicesCreateService) Do(ctx context.Context) (*IndicesCreateResult, er if s.timeout != "" { params.Set("timeout", s.timeout) } + if v := s.includeTypeName; v != nil { + params.Set("include_type_name", fmt.Sprint(*v)) + } // Setup HTTP request body var body interface{} diff --git a/indices_put_mapping.go b/indices_put_mapping.go index eae320ac..250ba2f5 100644 --- a/indices_put_mapping.go +++ b/indices_put_mapping.go @@ -33,7 +33,8 @@ type IndicesPutMappingService struct { ignoreUnavailable *bool allowNoIndices *bool expandWildcards string - updateAllTypes *bool + includeTypeName *bool + writeIndexOnly *bool timeout string bodyJson map[string]interface{} bodyString string @@ -134,10 +135,15 @@ func (s *IndicesPutMappingService) ExpandWildcards(expandWildcards string) *Indi return s } -// UpdateAllTypes, if true, indicates that all fields that span multiple indices -// should be updated (default: false). -func (s *IndicesPutMappingService) UpdateAllTypes(updateAllTypes bool) *IndicesPutMappingService { - s.updateAllTypes = &updateAllTypes +// IncludeTypeName indicates whether a type should be expected in the body of the mappings. +func (s *IndicesPutMappingService) IncludeTypeName(includeTypeName bool) *IndicesPutMappingService { + s.includeTypeName = &includeTypeName + return s +} + +// WriteIndexOnly, when true, applies mappings only to the write index of an alias or data stream. +func (s *IndicesPutMappingService) WriteIndexOnly(writeIndexOnly bool) *IndicesPutMappingService { + s.writeIndexOnly = &writeIndexOnly return s } @@ -177,16 +183,19 @@ func (s *IndicesPutMappingService) buildURL() (string, url.Values, error) { params.Set("filter_path", strings.Join(s.filterPath, ",")) } if s.ignoreUnavailable != nil { - params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable)) + params.Set("ignore_unavailable", fmt.Sprint(*s.ignoreUnavailable)) } if s.allowNoIndices != nil { - params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices)) + params.Set("allow_no_indices", fmt.Sprint(*s.allowNoIndices)) } if s.expandWildcards != "" { params.Set("expand_wildcards", s.expandWildcards) } - if s.updateAllTypes != nil { - params.Set("update_all_types", fmt.Sprintf("%v", *s.updateAllTypes)) + if s.includeTypeName != nil { + params.Set("include_type_name", fmt.Sprint(*s.includeTypeName)) + } + if s.writeIndexOnly != nil { + params.Set("write_index_only", fmt.Sprint(*s.writeIndexOnly)) } if s.timeout != "" { params.Set("timeout", s.timeout) diff --git a/indices_put_template.go b/indices_put_template.go index bafa81ed..fefa1b24 100644 --- a/indices_put_template.go +++ b/indices_put_template.go @@ -31,16 +31,17 @@ type IndicesPutTemplateService struct { filterPath []string // list of filters used to reduce the response headers http.Header // custom request-level HTTP headers - name string - cause string - order interface{} - version *int - create *bool - timeout string - masterTimeout string - flatSettings *bool - bodyJson interface{} - bodyString string + name string + cause string + order interface{} + version *int + create *bool + timeout string + masterTimeout string + flatSettings *bool + includeTypeName *bool + bodyJson interface{} + bodyString string } // NewIndicesPutTemplateService creates a new IndicesPutTemplateService. @@ -115,6 +116,12 @@ func (s *IndicesPutTemplateService) MasterTimeout(masterTimeout string) *Indices return s } +// IncludeTypeName indicates whether a type should be expected in the body of the mappings. +func (s *IndicesPutTemplateService) IncludeTypeName(includeTypeName bool) *IndicesPutTemplateService { + s.includeTypeName = &includeTypeName + return s +} + // FlatSettings indicates whether to return settings in flat format (default: false). func (s *IndicesPutTemplateService) FlatSettings(flatSettings bool) *IndicesPutTemplateService { s.flatSettings = &flatSettings @@ -181,10 +188,10 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) { params.Set("order", fmt.Sprintf("%v", s.order)) } if s.version != nil { - params.Set("version", fmt.Sprintf("%v", *s.version)) + params.Set("version", fmt.Sprint(*s.version)) } if s.create != nil { - params.Set("create", fmt.Sprintf("%v", *s.create)) + params.Set("create", fmt.Sprint(*s.create)) } if s.cause != "" { params.Set("cause", s.cause) @@ -196,7 +203,10 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) { params.Set("master_timeout", s.masterTimeout) } if s.flatSettings != nil { - params.Set("flat_settings", fmt.Sprintf("%v", *s.flatSettings)) + params.Set("flat_settings", fmt.Sprint(*s.flatSettings)) + } + if s.includeTypeName != nil { + params.Set("include_type_name", fmt.Sprint(*s.includeTypeName)) } return path, params, nil }