func (s *IndexService) Do(ctx context.Context) (*IndexResponse, error) {
	if err := s.Validate(); err != nil {
		return nil, err
	}
	method, path, params, err := s.buildURL()
	if err != nil {
		return nil, err
	}
	var body interface{}
	if s.bodyJson != nil {
		body = s.bodyJson
	} else {
		body = s.bodyString
	}
	res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
		Method:  method,
		Path:    path,
		Params:  params,
		Body:    body,
		Headers: s.headers,
	})
	if err != nil {
		return nil, err
	}
	ret := new(IndexResponse)
	if err := s.client.decoder.Decode(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
Do executes the operation.
package elastic
import (
	"context"
	"fmt"
	"net/http"
	"net/url"
	"strings"
	"github.com/olivere/elastic/v7/uritemplates"
)
type IndexService struct {
	client *Client
	pretty     *bool        
	human      *bool        
	errorTrace *bool        
	filterPath []string     
	headers    http.Header  
	id                  string
	index               string
	typ                 string
	parent              string
	routing             string
	timeout             string
	timestamp           string
	ttl                 string
	version             interface{}
	opType              string
	versionType         string
	refresh             string
	waitForActiveShards string
	pipeline            string
	ifSeqNo             *int64
	ifPrimaryTerm       *int64
	bodyJson            interface{}
	bodyString          string
}
func NewIndexService(client *Client) *IndexService {
	return &IndexService{
		client: client,
		typ:    "_doc",
	}
}
func (s *IndexService) Pretty(pretty bool) *IndexService {
	s.pretty = &pretty
	return s
}
func (s *IndexService) Human(human bool) *IndexService {
	s.human = &human
	return s
}
func (s *IndexService) ErrorTrace(errorTrace bool) *IndexService {
	s.errorTrace = &errorTrace
	return s
}
func (s *IndexService) FilterPath(filterPath ...string) *IndexService {
	s.filterPath = filterPath
	return s
}
func (s *IndexService) Header(name string, value string) *IndexService {
	if s.headers == nil {
		s.headers = http.Header{}
	}
	s.headers.Add(name, value)
	return s
}
func (s *IndexService) Headers(headers http.Header) *IndexService {
	s.headers = headers
	return s
}
func (s *IndexService) Id(id string) *IndexService {
	s.id = id
	return s
}
func (s *IndexService) Index(index string) *IndexService {
	s.index = index
	return s
}
func (s *IndexService) Type(typ string) *IndexService {
	s.typ = typ
	return s
}
func (s *IndexService) WaitForActiveShards(waitForActiveShards string) *IndexService {
	s.waitForActiveShards = waitForActiveShards
	return s
}
func (s *IndexService) Pipeline(pipeline string) *IndexService {
	s.pipeline = pipeline
	return s
}
func (s *IndexService) Refresh(refresh string) *IndexService {
	s.refresh = refresh
	return s
}
func (s *IndexService) Ttl(ttl string) *IndexService {
	s.ttl = ttl
	return s
}
func (s *IndexService) TTL(ttl string) *IndexService {
	s.ttl = ttl
	return s
}
func (s *IndexService) Version(version interface{}) *IndexService {
	s.version = version
	return s
}
func (s *IndexService) OpType(opType string) *IndexService {
	s.opType = opType
	return s
}
func (s *IndexService) Parent(parent string) *IndexService {
	s.parent = parent
	return s
}
func (s *IndexService) Routing(routing string) *IndexService {
	s.routing = routing
	return s
}
func (s *IndexService) Timeout(timeout string) *IndexService {
	s.timeout = timeout
	return s
}
func (s *IndexService) Timestamp(timestamp string) *IndexService {
	s.timestamp = timestamp
	return s
}
func (s *IndexService) VersionType(versionType string) *IndexService {
	s.versionType = versionType
	return s
}
func (s *IndexService) IfSeqNo(seqNo int64) *IndexService {
	s.ifSeqNo = &seqNo
	return s
}
func (s *IndexService) IfPrimaryTerm(primaryTerm int64) *IndexService {
	s.ifPrimaryTerm = &primaryTerm
	return s
}
func (s *IndexService) BodyJson(body interface{}) *IndexService {
	s.bodyJson = body
	return s
}
func (s *IndexService) BodyString(body string) *IndexService {
	s.bodyString = body
	return s
}
func (s *IndexService) buildURL() (string, string, url.Values, error) {
	var err error
	var method, path string
	if s.id != "" {
		method = "PUT"
		path, err = uritemplates.Expand("/{index}/{type}/{id}", map[string]string{
			"id":    s.id,
			"index": s.index,
			"type":  s.typ,
		})
	} else {
		method = "POST"
		path, err = uritemplates.Expand("/{index}/{type}/", map[string]string{
			"index": s.index,
			"type":  s.typ,
		})
	}
	if err != nil {
		return "", "", url.Values{}, err
	}
	params := url.Values{}
	if v := s.pretty; v != nil {
		params.Set("pretty", fmt.Sprint(*v))
	}
	if v := s.human; v != nil {
		params.Set("human", fmt.Sprint(*v))
	}
	if v := s.errorTrace; v != nil {
		params.Set("error_trace", fmt.Sprint(*v))
	}
	if len(s.filterPath) > 0 {
		params.Set("filter_path", strings.Join(s.filterPath, ","))
	}
	if s.waitForActiveShards != "" {
		params.Set("wait_for_active_shards", s.waitForActiveShards)
	}
	if s.refresh != "" {
		params.Set("refresh", s.refresh)
	}
	if s.opType != "" {
		params.Set("op_type", s.opType)
	}
	if s.parent != "" {
		params.Set("parent", s.parent)
	}
	if s.pipeline != "" {
		params.Set("pipeline", s.pipeline)
	}
	if s.routing != "" {
		params.Set("routing", s.routing)
	}
	if s.timeout != "" {
		params.Set("timeout", s.timeout)
	}
	if s.timestamp != "" {
		params.Set("timestamp", s.timestamp)
	}
	if s.ttl != "" {
		params.Set("ttl", s.ttl)
	}
	if s.version != nil {
		params.Set("version", fmt.Sprintf("%v", s.version))
	}
	if s.versionType != "" {
		params.Set("version_type", s.versionType)
	}
	if v := s.ifSeqNo; v != nil {
		params.Set("if_seq_no", fmt.Sprintf("%d", *v))
	}
	if v := s.ifPrimaryTerm; v != nil {
		params.Set("if_primary_term", fmt.Sprintf("%d", *v))
	}
	return method, path, params, nil
}
func (s *IndexService) Validate() error {
	var invalid []string
	if s.index == "" {
		invalid = append(invalid, "Index")
	}
	if s.typ == "" {
		invalid = append(invalid, "Type")
	}
	if s.bodyString == "" && s.bodyJson == nil {
		invalid = append(invalid, "BodyJson")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}