func (f Search) WithSize(v int) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Size = &v
	}
}
WithSize - number of hits to return (default: 10).
package opensearchapi
import (
	"context"
	"fmt"
	"io"
	"net/http"
	"strconv"
	"strings"
	"time"
)
func newSearchFunc(t Transport) Search {
	return func(o ...func(*SearchRequest)) (*Response, error) {
		var r = SearchRequest{}
		for _, f := range o {
			f(&r)
		}
		return r.Do(r.ctx, t)
	}
}
type Search func(o ...func(*SearchRequest)) (*Response, error)
type SearchRequest struct {
	Index        []string
	DocumentType []string
	Body io.Reader
	AllowNoIndices             *bool
	AllowPartialSearchResults  *bool
	Analyzer                   string
	AnalyzeWildcard            *bool
	BatchedReduceSize          *int
	CcsMinimizeRoundtrips      *bool
	DefaultOperator            string
	Df                         string
	DocvalueFields             []string
	ExpandWildcards            string
	Explain                    *bool
	From                       *int
	IgnoreThrottled            *bool
	IgnoreUnavailable          *bool
	Lenient                    *bool
	MaxConcurrentShardRequests *int
	MinCompatibleShardNode     string
	Preference                 string
	PreFilterShardSize         *int
	Query                      string
	RequestCache               *bool
	RestTotalHitsAsInt         *bool
	Routing                    []string
	Scroll                     time.Duration
	SearchType                 string
	SeqNoPrimaryTerm           *bool
	Size                       *int
	Sort                       []string
	Source                     []string
	SourceExcludes             []string
	SourceIncludes             []string
	Stats                      []string
	StoredFields               []string
	SuggestField               string
	SuggestMode                string
	SuggestSize                *int
	SuggestText                string
	TerminateAfter             *int
	Timeout                    time.Duration
	TrackScores                *bool
	TrackTotalHits             interface{}
	TypedKeys                  *bool
	Version                    *bool
	Pretty     bool
	Human      bool
	ErrorTrace bool
	FilterPath []string
	Header http.Header
	ctx context.Context
}
func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
	var (
		method string
		path   strings.Builder
		params map[string]string
	)
	method = "POST"
	path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_search"))
	if len(r.Index) > 0 {
		path.WriteString("/")
		path.WriteString(strings.Join(r.Index, ","))
	}
	if len(r.DocumentType) > 0 {
		path.WriteString("/")
		path.WriteString(strings.Join(r.DocumentType, ","))
	}
	path.WriteString("/")
	path.WriteString("_search")
	params = make(map[string]string)
	if r.AllowNoIndices != nil {
		params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices)
	}
	if r.AllowPartialSearchResults != nil {
		params["allow_partial_search_results"] = strconv.FormatBool(*r.AllowPartialSearchResults)
	}
	if r.Analyzer != "" {
		params["analyzer"] = r.Analyzer
	}
	if r.AnalyzeWildcard != nil {
		params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard)
	}
	if r.BatchedReduceSize != nil {
		params["batched_reduce_size"] = strconv.FormatInt(int64(*r.BatchedReduceSize), 10)
	}
	if r.CcsMinimizeRoundtrips != nil {
		params["ccs_minimize_roundtrips"] = strconv.FormatBool(*r.CcsMinimizeRoundtrips)
	}
	if r.DefaultOperator != "" {
		params["default_operator"] = r.DefaultOperator
	}
	if r.Df != "" {
		params["df"] = r.Df
	}
	if len(r.DocvalueFields) > 0 {
		params["docvalue_fields"] = strings.Join(r.DocvalueFields, ",")
	}
	if r.ExpandWildcards != "" {
		params["expand_wildcards"] = r.ExpandWildcards
	}
	if r.Explain != nil {
		params["explain"] = strconv.FormatBool(*r.Explain)
	}
	if r.From != nil {
		params["from"] = strconv.FormatInt(int64(*r.From), 10)
	}
	if r.IgnoreThrottled != nil {
		params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled)
	}
	if r.IgnoreUnavailable != nil {
		params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable)
	}
	if r.Lenient != nil {
		params["lenient"] = strconv.FormatBool(*r.Lenient)
	}
	if r.MaxConcurrentShardRequests != nil {
		params["max_concurrent_shard_requests"] = strconv.FormatInt(int64(*r.MaxConcurrentShardRequests), 10)
	}
	if r.MinCompatibleShardNode != "" {
		params["min_compatible_shard_node"] = r.MinCompatibleShardNode
	}
	if r.Preference != "" {
		params["preference"] = r.Preference
	}
	if r.PreFilterShardSize != nil {
		params["pre_filter_shard_size"] = strconv.FormatInt(int64(*r.PreFilterShardSize), 10)
	}
	if r.Query != "" {
		params["q"] = r.Query
	}
	if r.RequestCache != nil {
		params["request_cache"] = strconv.FormatBool(*r.RequestCache)
	}
	if r.RestTotalHitsAsInt != nil {
		params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt)
	}
	if len(r.Routing) > 0 {
		params["routing"] = strings.Join(r.Routing, ",")
	}
	if r.Scroll != 0 {
		params["scroll"] = formatDuration(r.Scroll)
	}
	if r.SearchType != "" {
		params["search_type"] = r.SearchType
	}
	if r.SeqNoPrimaryTerm != nil {
		params["seq_no_primary_term"] = strconv.FormatBool(*r.SeqNoPrimaryTerm)
	}
	if r.Size != nil {
		params["size"] = strconv.FormatInt(int64(*r.Size), 10)
	}
	if len(r.Sort) > 0 {
		params["sort"] = strings.Join(r.Sort, ",")
	}
	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.Stats) > 0 {
		params["stats"] = strings.Join(r.Stats, ",")
	}
	if len(r.StoredFields) > 0 {
		params["stored_fields"] = strings.Join(r.StoredFields, ",")
	}
	if r.SuggestField != "" {
		params["suggest_field"] = r.SuggestField
	}
	if r.SuggestMode != "" {
		params["suggest_mode"] = r.SuggestMode
	}
	if r.SuggestSize != nil {
		params["suggest_size"] = strconv.FormatInt(int64(*r.SuggestSize), 10)
	}
	if r.SuggestText != "" {
		params["suggest_text"] = r.SuggestText
	}
	if r.TerminateAfter != nil {
		params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10)
	}
	if r.Timeout != 0 {
		params["timeout"] = formatDuration(r.Timeout)
	}
	if r.TrackScores != nil {
		params["track_scores"] = strconv.FormatBool(*r.TrackScores)
	}
	if r.TrackTotalHits != nil {
		params["track_total_hits"] = fmt.Sprintf("%v", r.TrackTotalHits)
	}
	if r.TypedKeys != nil {
		params["typed_keys"] = strconv.FormatBool(*r.TypedKeys)
	}
	if r.Version != nil {
		params["version"] = strconv.FormatBool(*r.Version)
	}
	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
}
func (f Search) WithContext(v context.Context) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.ctx = v
	}
}
func (f Search) WithBody(v io.Reader) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Body = v
	}
}
func (f Search) WithIndex(v ...string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Index = v
	}
}
func (f Search) WithDocumentType(v ...string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.DocumentType = v
	}
}
func (f Search) WithAllowNoIndices(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.AllowNoIndices = &v
	}
}
func (f Search) WithAllowPartialSearchResults(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.AllowPartialSearchResults = &v
	}
}
func (f Search) WithAnalyzer(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Analyzer = v
	}
}
func (f Search) WithAnalyzeWildcard(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.AnalyzeWildcard = &v
	}
}
func (f Search) WithBatchedReduceSize(v int) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.BatchedReduceSize = &v
	}
}
func (f Search) WithCcsMinimizeRoundtrips(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.CcsMinimizeRoundtrips = &v
	}
}
func (f Search) WithDefaultOperator(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.DefaultOperator = v
	}
}
func (f Search) WithDf(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Df = v
	}
}
func (f Search) WithDocvalueFields(v ...string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.DocvalueFields = v
	}
}
func (f Search) WithExpandWildcards(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.ExpandWildcards = v
	}
}
func (f Search) WithExplain(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Explain = &v
	}
}
func (f Search) WithFrom(v int) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.From = &v
	}
}
func (f Search) WithIgnoreThrottled(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.IgnoreThrottled = &v
	}
}
func (f Search) WithIgnoreUnavailable(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.IgnoreUnavailable = &v
	}
}
func (f Search) WithLenient(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Lenient = &v
	}
}
func (f Search) WithMaxConcurrentShardRequests(v int) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.MaxConcurrentShardRequests = &v
	}
}
func (f Search) WithMinCompatibleShardNode(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.MinCompatibleShardNode = v
	}
}
func (f Search) WithPreference(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Preference = v
	}
}
func (f Search) WithPreFilterShardSize(v int) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.PreFilterShardSize = &v
	}
}
func (f Search) WithQuery(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Query = v
	}
}
func (f Search) WithRequestCache(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.RequestCache = &v
	}
}
func (f Search) WithRestTotalHitsAsInt(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.RestTotalHitsAsInt = &v
	}
}
func (f Search) WithRouting(v ...string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Routing = v
	}
}
func (f Search) WithScroll(v time.Duration) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.Scroll = v
	}
}
func (f Search) WithSearchType(v string) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.SearchType = v
	}
}
func (f Search) WithSeqNoPrimaryTerm(v bool) func(*SearchRequest) {
	return func(r *SearchRequest) {
		r.SeqNoPrimaryTerm = &v
	}
}