func (s *CountService) buildURL() (string, url.Values, error) {
	var err error
	var path string
	if len(s.index) > 0 && len(s.typ) > 0 {
		path, err = uritemplates.Expand("/{index}/{type}/_count", map[string]string{
			"index": strings.Join(s.index, ","),
			"type":  strings.Join(s.typ, ","),
		})
	} else if len(s.index) > 0 {
		path, err = uritemplates.Expand("/{index}/_count", map[string]string{
			"index": strings.Join(s.index, ","),
		})
	} else if len(s.typ) > 0 {
		path, err = uritemplates.Expand("/_all/{type}/_count", map[string]string{
			"type": strings.Join(s.typ, ","),
		})
	} else {
		path = "/_all/_count"
	}
	if err != nil {
		return "", url.Values{}, err
	}
	params := url.Values{}
	if s.pretty {
		params.Set("pretty", "true")
	}
	if s.allowNoIndices != nil {
		params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
	}
	if s.analyzeWildcard != nil {
		params.Set("analyze_wildcard", fmt.Sprintf("%v", *s.analyzeWildcard))
	}
	if s.analyzer != "" {
		params.Set("analyzer", s.analyzer)
	}
	if s.defaultOperator != "" {
		params.Set("default_operator", s.defaultOperator)
	}
	if s.df != "" {
		params.Set("df", s.df)
	}
	if s.expandWildcards != "" {
		params.Set("expand_wildcards", s.expandWildcards)
	}
	if s.ignoreUnavailable != nil {
		params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
	}
	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.minScore != nil {
		params.Set("min_score", fmt.Sprintf("%v", s.minScore))
	}
	if s.preference != "" {
		params.Set("preference", s.preference)
	}
	if s.q != "" {
		params.Set("q", s.q)
	}
	if s.routing != "" {
		params.Set("routing", s.routing)
	}
	return path, params, nil
}
buildURL builds the URL for the operation.
package elastic
import (
	"context"
	"fmt"
	"net/url"
	"strings"
	"github.com/olivere/elastic/uritemplates"
)
type CountService struct {
	client                 *Client
	pretty                 bool
	index                  []string
	typ                    []string
	allowNoIndices         *bool
	analyzeWildcard        *bool
	analyzer               string
	defaultOperator        string
	df                     string
	expandWildcards        string
	ignoreUnavailable      *bool
	lenient                *bool
	lowercaseExpandedTerms *bool
	minScore               interface{}
	preference             string
	q                      string
	query                  Query
	routing                string
	bodyJson               interface{}
	bodyString             string
}
func NewCountService(client *Client) *CountService {
	return &CountService{
		client: client,
	}
}
func (s *CountService) Index(index ...string) *CountService {
	if s.index == nil {
		s.index = make([]string, 0)
	}
	s.index = append(s.index, index...)
	return s
}
func (s *CountService) Type(typ ...string) *CountService {
	if s.typ == nil {
		s.typ = make([]string, 0)
	}
	s.typ = append(s.typ, typ...)
	return s
}
func (s *CountService) AllowNoIndices(allowNoIndices bool) *CountService {
	s.allowNoIndices = &allowNoIndices
	return s
}
func (s *CountService) AnalyzeWildcard(analyzeWildcard bool) *CountService {
	s.analyzeWildcard = &analyzeWildcard
	return s
}
func (s *CountService) Analyzer(analyzer string) *CountService {
	s.analyzer = analyzer
	return s
}
func (s *CountService) DefaultOperator(defaultOperator string) *CountService {
	s.defaultOperator = defaultOperator
	return s
}
func (s *CountService) Df(df string) *CountService {
	s.df = df
	return s
}
func (s *CountService) ExpandWildcards(expandWildcards string) *CountService {
	s.expandWildcards = expandWildcards
	return s
}
func (s *CountService) IgnoreUnavailable(ignoreUnavailable bool) *CountService {
	s.ignoreUnavailable = &ignoreUnavailable
	return s
}
func (s *CountService) Lenient(lenient bool) *CountService {
	s.lenient = &lenient
	return s
}
func (s *CountService) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *CountService {
	s.lowercaseExpandedTerms = &lowercaseExpandedTerms
	return s
}
func (s *CountService) MinScore(minScore interface{}) *CountService {
	s.minScore = minScore
	return s
}
func (s *CountService) Preference(preference string) *CountService {
	s.preference = preference
	return s
}
func (s *CountService) Q(q string) *CountService {
	s.q = q
	return s
}
func (s *CountService) Query(query Query) *CountService {
	s.query = query
	return s
}
func (s *CountService) Routing(routing string) *CountService {
	s.routing = routing
	return s
}
func (s *CountService) Pretty(pretty bool) *CountService {
	s.pretty = pretty
	return s
}
func (s *CountService) BodyJson(body interface{}) *CountService {
	s.bodyJson = body
	return s
}
func (s *CountService) BodyString(body string) *CountService {
	s.bodyString = body
	return s
}