Skip to content

Commit a5767e3

Browse files
committed
Fix Indices API to reflect current API
This commit fixes several Indices-related APIs to reflect the current state of the API.
1 parent 4fa5c50 commit a5767e3

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed

indices_create.go

+15-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ type IndicesCreateService struct {
2828
filterPath []string // list of filters used to reduce the response
2929
headers http.Header // custom request-level HTTP headers
3030

31-
index string
32-
timeout string
33-
masterTimeout string
34-
bodyJson interface{}
35-
bodyString string
31+
index string
32+
timeout string
33+
masterTimeout string
34+
includeTypeName *bool
35+
bodyJson interface{}
36+
bodyString string
3637
}
3738

3839
// NewIndicesCreateService returns a new IndicesCreateService.
@@ -98,6 +99,12 @@ func (s *IndicesCreateService) MasterTimeout(masterTimeout string) *IndicesCreat
9899
return s
99100
}
100101

102+
// IncludeTypeName indicates whether a type should be expected in the body of the mappings.
103+
func (s *IndicesCreateService) IncludeTypeName(includeTypeName bool) *IndicesCreateService {
104+
s.includeTypeName = &includeTypeName
105+
return s
106+
}
107+
101108
// Body specifies the configuration of the index as a string.
102109
// It is an alias for BodyString.
103110
func (s *IndicesCreateService) Body(body string) *IndicesCreateService {
@@ -151,6 +158,9 @@ func (s *IndicesCreateService) Do(ctx context.Context) (*IndicesCreateResult, er
151158
if s.timeout != "" {
152159
params.Set("timeout", s.timeout)
153160
}
161+
if v := s.includeTypeName; v != nil {
162+
params.Set("include_type_name", fmt.Sprint(*v))
163+
}
154164

155165
// Setup HTTP request body
156166
var body interface{}

indices_put_mapping.go

+18-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ type IndicesPutMappingService struct {
3333
ignoreUnavailable *bool
3434
allowNoIndices *bool
3535
expandWildcards string
36-
updateAllTypes *bool
36+
includeTypeName *bool
37+
writeIndexOnly *bool
3738
timeout string
3839
bodyJson map[string]interface{}
3940
bodyString string
@@ -134,10 +135,15 @@ func (s *IndicesPutMappingService) ExpandWildcards(expandWildcards string) *Indi
134135
return s
135136
}
136137

137-
// UpdateAllTypes, if true, indicates that all fields that span multiple indices
138-
// should be updated (default: false).
139-
func (s *IndicesPutMappingService) UpdateAllTypes(updateAllTypes bool) *IndicesPutMappingService {
140-
s.updateAllTypes = &updateAllTypes
138+
// IncludeTypeName indicates whether a type should be expected in the body of the mappings.
139+
func (s *IndicesPutMappingService) IncludeTypeName(includeTypeName bool) *IndicesPutMappingService {
140+
s.includeTypeName = &includeTypeName
141+
return s
142+
}
143+
144+
// WriteIndexOnly, when true, applies mappings only to the write index of an alias or data stream.
145+
func (s *IndicesPutMappingService) WriteIndexOnly(writeIndexOnly bool) *IndicesPutMappingService {
146+
s.writeIndexOnly = &writeIndexOnly
141147
return s
142148
}
143149

@@ -177,16 +183,19 @@ func (s *IndicesPutMappingService) buildURL() (string, url.Values, error) {
177183
params.Set("filter_path", strings.Join(s.filterPath, ","))
178184
}
179185
if s.ignoreUnavailable != nil {
180-
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
186+
params.Set("ignore_unavailable", fmt.Sprint(*s.ignoreUnavailable))
181187
}
182188
if s.allowNoIndices != nil {
183-
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
189+
params.Set("allow_no_indices", fmt.Sprint(*s.allowNoIndices))
184190
}
185191
if s.expandWildcards != "" {
186192
params.Set("expand_wildcards", s.expandWildcards)
187193
}
188-
if s.updateAllTypes != nil {
189-
params.Set("update_all_types", fmt.Sprintf("%v", *s.updateAllTypes))
194+
if s.includeTypeName != nil {
195+
params.Set("include_type_name", fmt.Sprint(*s.includeTypeName))
196+
}
197+
if s.writeIndexOnly != nil {
198+
params.Set("write_index_only", fmt.Sprint(*s.writeIndexOnly))
190199
}
191200
if s.timeout != "" {
192201
params.Set("timeout", s.timeout)

indices_put_template.go

+23-13
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ type IndicesPutTemplateService struct {
3131
filterPath []string // list of filters used to reduce the response
3232
headers http.Header // custom request-level HTTP headers
3333

34-
name string
35-
cause string
36-
order interface{}
37-
version *int
38-
create *bool
39-
timeout string
40-
masterTimeout string
41-
flatSettings *bool
42-
bodyJson interface{}
43-
bodyString string
34+
name string
35+
cause string
36+
order interface{}
37+
version *int
38+
create *bool
39+
timeout string
40+
masterTimeout string
41+
flatSettings *bool
42+
includeTypeName *bool
43+
bodyJson interface{}
44+
bodyString string
4445
}
4546

4647
// NewIndicesPutTemplateService creates a new IndicesPutTemplateService.
@@ -115,6 +116,12 @@ func (s *IndicesPutTemplateService) MasterTimeout(masterTimeout string) *Indices
115116
return s
116117
}
117118

119+
// IncludeTypeName indicates whether a type should be expected in the body of the mappings.
120+
func (s *IndicesPutTemplateService) IncludeTypeName(includeTypeName bool) *IndicesPutTemplateService {
121+
s.includeTypeName = &includeTypeName
122+
return s
123+
}
124+
118125
// FlatSettings indicates whether to return settings in flat format (default: false).
119126
func (s *IndicesPutTemplateService) FlatSettings(flatSettings bool) *IndicesPutTemplateService {
120127
s.flatSettings = &flatSettings
@@ -181,10 +188,10 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) {
181188
params.Set("order", fmt.Sprintf("%v", s.order))
182189
}
183190
if s.version != nil {
184-
params.Set("version", fmt.Sprintf("%v", *s.version))
191+
params.Set("version", fmt.Sprint(*s.version))
185192
}
186193
if s.create != nil {
187-
params.Set("create", fmt.Sprintf("%v", *s.create))
194+
params.Set("create", fmt.Sprint(*s.create))
188195
}
189196
if s.cause != "" {
190197
params.Set("cause", s.cause)
@@ -196,7 +203,10 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) {
196203
params.Set("master_timeout", s.masterTimeout)
197204
}
198205
if s.flatSettings != nil {
199-
params.Set("flat_settings", fmt.Sprintf("%v", *s.flatSettings))
206+
params.Set("flat_settings", fmt.Sprint(*s.flatSettings))
207+
}
208+
if s.includeTypeName != nil {
209+
params.Set("include_type_name", fmt.Sprint(*s.includeTypeName))
200210
}
201211
return path, params, nil
202212
}

0 commit comments

Comments
 (0)