func (s *DeleteByQueryService) Do(ctx context.Context) (*BulkIndexByScrollResponse, error) {
	if err := s.Validate(); err != nil {
		return nil, err
	}
	path, params, err := s.buildURL()
	if err != nil {
		return nil, err
	}
	var body interface{}
	if s.body != nil {
		body = s.body
	} else if s.query != nil {
		src, err := s.query.Source()
		if err != nil {
			return nil, err
		}
		body = map[string]interface{}{
			"query": src,
		}
	}
	res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
	if err != nil {
		return nil, err
	}
	ret := new(BulkIndexByScrollResponse)
	if err := s.client.decoder.Decode(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
Do executes the delete-by-query operation.
package elastic
import (
	"context"
	"fmt"
	"net/url"
	"strings"
	"gopkg.in/olivere/elastic.v5/uritemplates"
)
type DeleteByQueryService struct {
	client                 *Client
	index                  []string
	typ                    []string
	query                  Query
	body                   interface{}
	xSource                []string
	xSourceExclude         []string
	xSourceInclude         []string
	analyzer               string
	analyzeWildcard        *bool
	allowNoIndices         *bool
	conflicts              string
	defaultOperator        string
	df                     string
	docvalueFields         []string
	expandWildcards        string
	explain                *bool
	from                   *int
	ignoreUnavailable      *bool
	lenient                *bool
	lowercaseExpandedTerms *bool
	preference             string
	q                      string
	refresh                string
	requestCache           *bool
	requestsPerSecond      *int
	routing                []string
	scroll                 string
	scrollSize             *int
	searchTimeout          string
	searchType             string
	size                   *int
	sort                   []string
	stats                  []string
	storedFields           []string
	suggestField           string
	suggestMode            string
	suggestSize            *int
	suggestText            string
	terminateAfter         *int
	timeout                string
	trackScores            *bool
	version                *bool
	waitForActiveShards    string
	waitForCompletion      *bool
	pretty                 bool
}
func NewDeleteByQueryService(client *Client) *DeleteByQueryService {
	builder := &DeleteByQueryService{
		client: client,
	}
	return builder
}
func (s *DeleteByQueryService) Index(index ...string) *DeleteByQueryService {
	s.index = append(s.index, index...)
	return s
}
func (s *DeleteByQueryService) Type(typ ...string) *DeleteByQueryService {
	s.typ = append(s.typ, typ...)
	return s
}
func (s *DeleteByQueryService) XSource(xSource ...string) *DeleteByQueryService {
	s.xSource = append(s.xSource, xSource...)
	return s
}
func (s *DeleteByQueryService) XSourceExclude(xSourceExclude ...string) *DeleteByQueryService {
	s.xSourceExclude = append(s.xSourceExclude, xSourceExclude...)
	return s
}
func (s *DeleteByQueryService) XSourceInclude(xSourceInclude ...string) *DeleteByQueryService {
	s.xSourceInclude = append(s.xSourceInclude, xSourceInclude...)
	return s
}
func (s *DeleteByQueryService) Analyzer(analyzer string) *DeleteByQueryService {
	s.analyzer = analyzer
	return s
}
func (s *DeleteByQueryService) AnalyzeWildcard(analyzeWildcard bool) *DeleteByQueryService {
	s.analyzeWildcard = &analyzeWildcard
	return s
}
func (s *DeleteByQueryService) AllowNoIndices(allow bool) *DeleteByQueryService {
	s.allowNoIndices = &allow
	return s
}
func (s *DeleteByQueryService) Conflicts(conflicts string) *DeleteByQueryService {
	s.conflicts = conflicts
	return s
}
func (s *DeleteByQueryService) AbortOnVersionConflict() *DeleteByQueryService {
	s.conflicts = "abort"
	return s
}
func (s *DeleteByQueryService) ProceedOnVersionConflict() *DeleteByQueryService {
	s.conflicts = "proceed"
	return s
}
func (s *DeleteByQueryService) DefaultOperator(defaultOperator string) *DeleteByQueryService {
	s.defaultOperator = defaultOperator
	return s
}
func (s *DeleteByQueryService) DF(defaultField string) *DeleteByQueryService {
	s.df = defaultField
	return s
}
func (s *DeleteByQueryService) DefaultField(defaultField string) *DeleteByQueryService {
	s.df = defaultField
	return s
}
func (s *DeleteByQueryService) DocvalueFields(docvalueFields ...string) *DeleteByQueryService {
	s.docvalueFields = docvalueFields
	return s
}
func (s *DeleteByQueryService) ExpandWildcards(expand string) *DeleteByQueryService {
	s.expandWildcards = expand
	return s
}
func (s *DeleteByQueryService) Explain(explain bool) *DeleteByQueryService {
	s.explain = &explain
	return s
}
func (s *DeleteByQueryService) From(from int) *DeleteByQueryService {
	s.from = &from
	return s
}
func (s *DeleteByQueryService) IgnoreUnavailable(ignore bool) *DeleteByQueryService {
	s.ignoreUnavailable = &ignore
	return s
}
func (s *DeleteByQueryService) Lenient(lenient bool) *DeleteByQueryService {
	s.lenient = &lenient
	return s
}
func (s *DeleteByQueryService) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *DeleteByQueryService {
	s.lowercaseExpandedTerms = &lowercaseExpandedTerms
	return s
}
func (s *DeleteByQueryService) Preference(preference string) *DeleteByQueryService {
	s.preference = preference
	return s
}
func (s *DeleteByQueryService) Q(query string) *DeleteByQueryService {
	s.q = query
	return s
}
func (s *DeleteByQueryService) QueryString(query string) *DeleteByQueryService {
	s.q = query
	return s
}
func (s *DeleteByQueryService) Query(query Query) *DeleteByQueryService {
	s.query = query
	return s
}
func (s *DeleteByQueryService) Refresh(refresh string) *DeleteByQueryService {
	s.refresh = refresh
	return s
}
func (s *DeleteByQueryService) RequestCache(requestCache bool) *DeleteByQueryService {
	s.requestCache = &requestCache
	return s
}
func (s *DeleteByQueryService) RequestsPerSecond(requestsPerSecond int) *DeleteByQueryService {
	s.requestsPerSecond = &requestsPerSecond
	return s
}
func (s *DeleteByQueryService) Routing(routing ...string) *DeleteByQueryService {
	s.routing = append(s.routing, routing...)
	return s
}
func (s *DeleteByQueryService) Scroll(scroll string) *DeleteByQueryService {
	s.scroll = scroll
	return s
}
func (s *DeleteByQueryService) ScrollSize(scrollSize int) *DeleteByQueryService {
	s.scrollSize = &scrollSize
	return s
}
func (s *DeleteByQueryService) SearchTimeout(searchTimeout string) *DeleteByQueryService {
	s.searchTimeout = searchTimeout
	return s
}
func (s *DeleteByQueryService) SearchType(searchType string) *DeleteByQueryService {
	s.searchType = searchType
	return s
}
func (s *DeleteByQueryService) Size(size int) *DeleteByQueryService {
	s.size = &size
	return s
}
func (s *DeleteByQueryService) Sort(sort ...string) *DeleteByQueryService {
	s.sort = append(s.sort, sort...)
	return s
}
func (s *DeleteByQueryService) SortByField(field string, ascending bool) *DeleteByQueryService {
	if ascending {
		s.sort = append(s.sort, fmt.Sprintf("%s:asc", field))
	} else {
		s.sort = append(s.sort, fmt.Sprintf("%s:desc", field))
	}
	return s
}
func (s *DeleteByQueryService) Stats(stats ...string) *DeleteByQueryService {
	s.stats = append(s.stats, stats...)
	return s
}
func (s *DeleteByQueryService) StoredFields(storedFields ...string) *DeleteByQueryService {
	s.storedFields = storedFields
	return s
}
func (s *DeleteByQueryService) SuggestField(suggestField string) *DeleteByQueryService {
	s.suggestField = suggestField
	return s
}
func (s *DeleteByQueryService) SuggestMode(suggestMode string) *DeleteByQueryService {
	s.suggestMode = suggestMode
	return s
}
func (s *DeleteByQueryService) SuggestSize(suggestSize int) *DeleteByQueryService {
	s.suggestSize = &suggestSize
	return s
}
func (s *DeleteByQueryService) SuggestText(suggestText string) *DeleteByQueryService {
	s.suggestText = suggestText
	return s
}
func (s *DeleteByQueryService) TerminateAfter(terminateAfter int) *DeleteByQueryService {
	s.terminateAfter = &terminateAfter
	return s
}
func (s *DeleteByQueryService) Timeout(timeout string) *DeleteByQueryService {
	s.timeout = timeout
	return s
}
func (s *DeleteByQueryService) TimeoutInMillis(timeoutInMillis int) *DeleteByQueryService {
	s.timeout = fmt.Sprintf("%dms", timeoutInMillis)
	return s
}
func (s *DeleteByQueryService) TrackScores(trackScores bool) *DeleteByQueryService {
	s.trackScores = &trackScores
	return s
}
func (s *DeleteByQueryService) Version(version bool) *DeleteByQueryService {
	s.version = &version
	return s
}
func (s *DeleteByQueryService) WaitForActiveShards(waitForActiveShards string) *DeleteByQueryService {
	s.waitForActiveShards = waitForActiveShards
	return s
}
func (s *DeleteByQueryService) WaitForCompletion(waitForCompletion bool) *DeleteByQueryService {
	s.waitForCompletion = &waitForCompletion
	return s
}
func (s *DeleteByQueryService) Pretty(pretty bool) *DeleteByQueryService {
	s.pretty = pretty
	return s
}
func (s *DeleteByQueryService) Body(body string) *DeleteByQueryService {
	s.body = body
	return s
}
func (s *DeleteByQueryService) buildURL() (string, url.Values, error) {
	var err error
	var path string
	if len(s.typ) > 0 {
		path, err = uritemplates.Expand("/{index}/{type}/_delete_by_query", map[string]string{
			"index": strings.Join(s.index, ","),
			"type":  strings.Join(s.typ, ","),
		})
	} else {
		path, err = uritemplates.Expand("/{index}/_delete_by_query", map[string]string{
			"index": strings.Join(s.index, ","),
		})
	}
	if err != nil {
		return "", url.Values{}, err
	}
	params := url.Values{}
	if len(s.xSource) > 0 {
		params.Set("_source", strings.Join(s.xSource, ","))
	}
	if len(s.xSourceExclude) > 0 {
		params.Set("_source_exclude", strings.Join(s.xSourceExclude, ","))
	}
	if len(s.xSourceInclude) > 0 {
		params.Set("_source_include", strings.Join(s.xSourceInclude, ","))
	}
	if s.analyzer != "" {
		params.Set("analyzer", s.analyzer)
	}
	if s.analyzeWildcard != nil {
		params.Set("analyze_wildcard", fmt.Sprintf("%v", *s.analyzeWildcard))
	}
	if s.defaultOperator != "" {
		params.Set("default_operator", s.defaultOperator)
	}
	if s.df != "" {
		params.Set("df", s.df)
	}
	if s.explain != nil {
		params.Set("explain", fmt.Sprintf("%v", *s.explain))
	}
	if len(s.storedFields) > 0 {
		params.Set("stored_fields", strings.Join(s.storedFields, ","))
	}
	if len(s.docvalueFields) > 0 {
		params.Set("docvalue_fields", strings.Join(s.docvalueFields, ","))
	}
	if s.from != nil {
		params.Set("from", fmt.Sprintf("%d", *s.from))
	}
	if s.ignoreUnavailable != nil {
		params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
	}
	if s.allowNoIndices != nil {
		params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
	}
	if s.conflicts != "" {
		params.Set("conflicts", s.conflicts)
	}
	if s.expandWildcards != "" {
		params.Set("expand_wildcards", s.expandWildcards)
	}
	if s.lenient != nil {
		params.Set("lenient", fmt.Sprintf("%v", *s.lenient))
	}
	if s.lowercaseExpandedTerms != nil {
		params.Set("lowercase_expanded_terms", fmt.Sprintf("%v", *s.lowercaseExpandedTerms))
	}
	if s.preference != "" {
		params.Set("preference", s.preference)
	}
	if s.q != "" {
		params.Set("q", s.q)
	}
	if len(s.routing) > 0 {
		params.Set("routing", strings.Join(s.routing, ","))
	}
	if s.scroll != "" {
		params.Set("scroll", s.scroll)
	}
	if s.searchType != "" {
		params.Set("search_type", s.searchType)
	}
	if s.searchTimeout != "" {
		params.Set("search_timeout", s.searchTimeout)
	}
	if s.size != nil {
		params.Set("size", fmt.Sprintf("%d", *s.size))
	}
	if len(s.sort) > 0 {
		params.Set("sort", strings.Join(s.sort, ","))
	}
	if s.terminateAfter != nil {
		params.Set("terminate_after", fmt.Sprintf("%v", *s.terminateAfter))
	}
	if len(s.stats) > 0 {
		params.Set("stats", strings.Join(s.stats, ","))
	}
	if s.suggestField != "" {
		params.Set("suggest_field", s.suggestField)
	}
	if s.suggestMode != "" {
		params.Set("suggest_mode", s.suggestMode)
	}
	if s.suggestSize != nil {
		params.Set("suggest_size", fmt.Sprintf("%v", *s.suggestSize))
	}
	if s.suggestText != "" {
		params.Set("suggest_text", s.suggestText)
	}
	if s.timeout != "" {
		params.Set("timeout", s.timeout)
	}
	if s.trackScores != nil {
		params.Set("track_scores", fmt.Sprintf("%v", *s.trackScores))
	}
	if s.version != nil {
		params.Set("version", fmt.Sprintf("%v", *s.version))
	}
	if s.requestCache != nil {
		params.Set("request_cache", fmt.Sprintf("%v", *s.requestCache))
	}
	if s.refresh != "" {
		params.Set("refresh", s.refresh)
	}
	if s.waitForActiveShards != "" {
		params.Set("wait_for_active_shards", s.waitForActiveShards)
	}
	if s.scrollSize != nil {
		params.Set("scroll_size", fmt.Sprintf("%d", *s.scrollSize))
	}
	if s.waitForCompletion != nil {
		params.Set("wait_for_completion", fmt.Sprintf("%v", *s.waitForCompletion))
	}
	if s.requestsPerSecond != nil {
		params.Set("requests_per_second", fmt.Sprintf("%v", *s.requestsPerSecond))
	}
	if s.pretty {
		params.Set("pretty", fmt.Sprintf("%v", s.pretty))
	}
	return path, params, nil
}
func (s *DeleteByQueryService) Validate() error {
	var invalid []string
	if len(s.index) == 0 {
		invalid = append(invalid, "Index")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}