Skip to content

Commit

Permalink
Add max_docs parameter to DeleteByQuery API
Browse files Browse the repository at this point in the history
This commit adds the missing `max_docs` parameter to the DeleteByQuery
API.

Close #1537
  • Loading branch information
olivere committed Oct 6, 2021
1 parent 556738f commit 9e03315
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions delete_by_query.go
Expand Up @@ -45,6 +45,7 @@ type DeleteByQueryService struct {
ignoreUnavailable *bool
lenient *bool
lowercaseExpandedTerms *bool
maxDocs *int
preference string
q string
refresh string
Expand Down Expand Up @@ -263,6 +264,13 @@ func (s *DeleteByQueryService) LowercaseExpandedTerms(lowercaseExpandedTerms boo
return s
}

// MaxDocs specifies the maximum number of documents to process.
// Defaults to all documents.
func (s *DeleteByQueryService) MaxDocs(maxDocs int) *DeleteByQueryService {
s.maxDocs = &maxDocs
return s
}

// Preference specifies the node or shard the operation should be performed on
// (default: random).
func (s *DeleteByQueryService) Preference(preference string) *DeleteByQueryService {
Expand Down Expand Up @@ -553,6 +561,9 @@ func (s *DeleteByQueryService) buildURL() (string, url.Values, error) {
if s.lowercaseExpandedTerms != nil {
params.Set("lowercase_expanded_terms", fmt.Sprintf("%v", *s.lowercaseExpandedTerms))
}
if s.maxDocs != nil {
params.Set("max_docs", fmt.Sprint(*s.maxDocs))
}
if s.preference != "" {
params.Set("preference", s.preference)
}
Expand Down

0 comments on commit 9e03315

Please sign in to comment.