Skip to content

Commit 9e03315

Browse files
committed
Add max_docs parameter to DeleteByQuery API
This commit adds the missing `max_docs` parameter to the DeleteByQuery API. Close #1537
1 parent 556738f commit 9e03315

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

delete_by_query.go

+11
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type DeleteByQueryService struct {
4545
ignoreUnavailable *bool
4646
lenient *bool
4747
lowercaseExpandedTerms *bool
48+
maxDocs *int
4849
preference string
4950
q string
5051
refresh string
@@ -263,6 +264,13 @@ func (s *DeleteByQueryService) LowercaseExpandedTerms(lowercaseExpandedTerms boo
263264
return s
264265
}
265266

267+
// MaxDocs specifies the maximum number of documents to process.
268+
// Defaults to all documents.
269+
func (s *DeleteByQueryService) MaxDocs(maxDocs int) *DeleteByQueryService {
270+
s.maxDocs = &maxDocs
271+
return s
272+
}
273+
266274
// Preference specifies the node or shard the operation should be performed on
267275
// (default: random).
268276
func (s *DeleteByQueryService) Preference(preference string) *DeleteByQueryService {
@@ -553,6 +561,9 @@ func (s *DeleteByQueryService) buildURL() (string, url.Values, error) {
553561
if s.lowercaseExpandedTerms != nil {
554562
params.Set("lowercase_expanded_terms", fmt.Sprintf("%v", *s.lowercaseExpandedTerms))
555563
}
564+
if s.maxDocs != nil {
565+
params.Set("max_docs", fmt.Sprint(*s.maxDocs))
566+
}
556567
if s.preference != "" {
557568
params.Set("preference", s.preference)
558569
}

0 commit comments

Comments
 (0)