func (s *FieldStatsService) Do() (*FieldStatsResponse, 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.bodyJson != nil {
		body = s.bodyJson
	} else {
		body = s.bodyString
	}
	res, err := s.client.PerformRequest("POST", path, params, body, http.StatusNotFound)
	if err != nil {
		return nil, err
	}
	if res.StatusCode == http.StatusNotFound {
		return &FieldStatsResponse{make(map[string]IndexFieldStats)}, nil
	}
	ret := new(FieldStatsResponse)
	if err := s.client.decoder.Decode(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
Do executes the operation.
package elastic
import (
	"fmt"
	"net/http"
	"net/url"
	"strings"
	"gopkg.in/olivere/elastic.v3/uritemplates"
)
const (
	FieldStatsClusterLevel = "cluster"
	FieldStatsIndicesLevel = "indices"
)
type FieldStatsService struct {
	client            *Client
	pretty            bool
	level             string
	index             []string
	allowNoIndices    *bool
	expandWildcards   string
	fields            []string
	ignoreUnavailable *bool
	bodyJson          interface{}
	bodyString        string
}
func NewFieldStatsService(client *Client) *FieldStatsService {
	return &FieldStatsService{
		client: client,
		index:  make([]string, 0),
		fields: make([]string, 0),
	}
}
func (s *FieldStatsService) Index(index ...string) *FieldStatsService {
	s.index = append(s.index, index...)
	return s
}
func (s *FieldStatsService) AllowNoIndices(allowNoIndices bool) *FieldStatsService {
	s.allowNoIndices = &allowNoIndices
	return s
}
func (s *FieldStatsService) ExpandWildcards(expandWildcards string) *FieldStatsService {
	s.expandWildcards = expandWildcards
	return s
}
func (s *FieldStatsService) Fields(fields ...string) *FieldStatsService {
	s.fields = append(s.fields, fields...)
	return s
}
func (s *FieldStatsService) IgnoreUnavailable(ignoreUnavailable bool) *FieldStatsService {
	s.ignoreUnavailable = &ignoreUnavailable
	return s
}
func (s *FieldStatsService) Level(level string) *FieldStatsService {
	s.level = level
	return s
}
func (s *FieldStatsService) ClusterLevel() *FieldStatsService {
	s.level = FieldStatsClusterLevel
	return s
}
func (s *FieldStatsService) IndicesLevel() *FieldStatsService {
	s.level = FieldStatsIndicesLevel
	return s
}
func (s *FieldStatsService) Pretty(pretty bool) *FieldStatsService {
	s.pretty = pretty
	return s
}
func (s *FieldStatsService) BodyJson(body interface{}) *FieldStatsService {
	s.bodyJson = body
	return s
}
func (s *FieldStatsService) BodyString(body string) *FieldStatsService {
	s.bodyString = body
	return s
}
func (s *FieldStatsService) buildURL() (string, url.Values, error) {
	var err error
	var path string
	if len(s.index) > 0 {
		path, err = uritemplates.Expand("/{index}/_field_stats", map[string]string{
			"index": strings.Join(s.index, ","),
		})
	} else {
		path = "/_field_stats"
	}
	if err != nil {
		return "", url.Values{}, err
	}
	params := url.Values{}
	if s.allowNoIndices != nil {
		params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
	}
	if s.expandWildcards != "" {
		params.Set("expand_wildcards", s.expandWildcards)
	}
	if len(s.fields) > 0 {
		params.Set("fields", strings.Join(s.fields, ","))
	}
	if s.ignoreUnavailable != nil {
		params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
	}
	if s.level != "" {
		params.Set("level", s.level)
	}
	return path, params, nil
}
func (s *FieldStatsService) Validate() error {
	var invalid []string
	if s.level != "" && (s.level != FieldStatsIndicesLevel && s.level != FieldStatsClusterLevel) {
		invalid = append(invalid, "Level")
	}
	if len(invalid) != 0 {
		return fmt.Errorf("missing or invalid required fields: %v", invalid)
	}
	return nil
}