func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
	var (
		method string
		path   strings.Builder
		params map[string]string
	)
	method = "POST"
	if r.DocumentType == "" {
		r.DocumentType = "_doc"
	}
	path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_explain"))
	path.WriteString("/")
	path.WriteString(r.Index)
	if r.DocumentType != "" {
		path.WriteString("/")
		path.WriteString(r.DocumentType)
	}
	path.WriteString("/")
	path.WriteString(r.DocumentID)
	path.WriteString("/")
	path.WriteString("_explain")
	params = make(map[string]string)
	if r.Analyzer != "" {
		params["analyzer"] = r.Analyzer
	}
	if r.AnalyzeWildcard != nil {
		params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard)
	}
	if r.DefaultOperator != "" {
		params["default_operator"] = r.DefaultOperator
	}
	if r.Df != "" {
		params["df"] = r.Df
	}
	if r.Lenient != nil {
		params["lenient"] = strconv.FormatBool(*r.Lenient)
	}
	if r.Preference != "" {
		params["preference"] = r.Preference
	}
	if r.Query != "" {
		params["q"] = r.Query
	}
	if r.Routing != "" {
		params["routing"] = r.Routing
	}
	if len(r.Source) > 0 {
		params["_source"] = strings.Join(r.Source, ",")
	}
	if len(r.SourceExcludes) > 0 {
		params["_source_excludes"] = strings.Join(r.SourceExcludes, ",")
	}
	if len(r.SourceIncludes) > 0 {
		params["_source_includes"] = strings.Join(r.SourceIncludes, ",")
	}
	if len(r.StoredFields) > 0 {
		params["stored_fields"] = strings.Join(r.StoredFields, ",")
	}
	if r.Pretty {
		params["pretty"] = "true"
	}
	if r.Human {
		params["human"] = "true"
	}
	if r.ErrorTrace {
		params["error_trace"] = "true"
	}
	if len(r.FilterPath) > 0 {
		params["filter_path"] = strings.Join(r.FilterPath, ",")
	}
	req, err := newRequest(method, path.String(), r.Body)
	if err != nil {
		return nil, err
	}
	if len(params) > 0 {
		q := req.URL.Query()
		for k, v := range params {
			q.Set(k, v)
		}
		req.URL.RawQuery = q.Encode()
	}
	if r.Body != nil {
		req.Header[headerContentType] = headerContentTypeJSON
	}
	if len(r.Header) > 0 {
		if len(req.Header) == 0 {
			req.Header = r.Header
		} else {
			for k, vv := range r.Header {
				for _, v := range vv {
					req.Header.Add(k, v)
				}
			}
		}
	}
	if ctx != nil {
		req = req.WithContext(ctx)
	}
	res, err := transport.Perform(req)
	if err != nil {
		return nil, err
	}
	response := Response{
		StatusCode: res.StatusCode,
		Body:       res.Body,
		Header:     res.Header,
	}
	return &response, nil
}
Do executes the request and returns response or error.
package opensearchapi
import (
	"context"
	"io"
	"net/http"
	"strconv"
	"strings"
)
func newExplainFunc(t Transport) Explain {
	return func(index string, id string, o ...func(*ExplainRequest)) (*Response, error) {
		var r = ExplainRequest{Index: index, DocumentID: id}
		for _, f := range o {
			f(&r)
		}
		return r.Do(r.ctx, t)
	}
}
type Explain func(index string, id string, o ...func(*ExplainRequest)) (*Response, error)
type ExplainRequest struct {
	Index        string
	DocumentType string
	DocumentID   string
	Body io.Reader
	Analyzer        string
	AnalyzeWildcard *bool
	DefaultOperator string
	Df              string
	Lenient         *bool
	Preference      string
	Query           string
	Routing         string
	Source          []string
	SourceExcludes  []string
	SourceIncludes  []string
	StoredFields    []string
	Pretty     bool
	Human      bool
	ErrorTrace bool
	FilterPath []string
	Header http.Header
	ctx context.Context
}