func (fs *TermvectorsFilterSettings) MaxDocFreq(value int64) *TermvectorsFilterSettings {
	fs.maxDocFreq = &value
	return fs
}
MaxDocFreq ignores terms which occur in more than this many docs.
package elastic
import (
	"fmt"
	"net/url"
	"strings"
	"gopkg.in/olivere/elastic.v3/uritemplates"
)
type TermvectorsService struct {
	client           *Client
	pretty           bool
	id               string
	index            string
	typ              string
	dfs              *bool
	doc              interface{}
	fieldStatistics  *bool
	fields           []string
	filter           *TermvectorsFilterSettings
	perFieldAnalyzer map[string]string
	offsets          *bool
	parent           string
	payloads         *bool
	positions        *bool
	preference       string
	realtime         *bool
	routing          string
	termStatistics   *bool
	version          interface{}
	versionType      string
	bodyJson         interface{}
	bodyString       string
}
func NewTermvectorsService(client *Client) *TermvectorsService {
	return &TermvectorsService{
		client: client,
	}
}
func (s *TermvectorsService) Index(index string) *TermvectorsService {
	s.index = index
	return s
}
func (s *TermvectorsService) Type(typ string) *TermvectorsService {
	s.typ = typ
	return s
}
func (s *TermvectorsService) Id(id string) *TermvectorsService {
	s.id = id
	return s
}
func (s *TermvectorsService) Dfs(dfs bool) *TermvectorsService {
	s.dfs = &dfs
	return s
}
func (s *TermvectorsService) Doc(doc interface{}) *TermvectorsService {
	s.doc = doc
	return s
}
func (s *TermvectorsService) FieldStatistics(fieldStatistics bool) *TermvectorsService {
	s.fieldStatistics = &fieldStatistics
	return s
}
func (s *TermvectorsService) Fields(fields ...string) *TermvectorsService {
	if s.fields == nil {
		s.fields = make([]string, 0)
	}
	s.fields = append(s.fields, fields...)
	return s
}
func (s *TermvectorsService) Filter(filter *TermvectorsFilterSettings) *TermvectorsService {
	s.filter = filter
	return s
}
func (s *TermvectorsService) PerFieldAnalyzer(perFieldAnalyzer map[string]string) *TermvectorsService {
	s.perFieldAnalyzer = perFieldAnalyzer
	return s
}
func (s *TermvectorsService) Offsets(offsets bool) *TermvectorsService {
	s.offsets = &offsets
	return s
}
func (s *TermvectorsService) Parent(parent string) *TermvectorsService {
	s.parent = parent
	return s
}
func (s *TermvectorsService) Payloads(payloads bool) *TermvectorsService {
	s.payloads = &payloads
	return s
}
func (s *TermvectorsService) Positions(positions bool) *TermvectorsService {
	s.positions = &positions
	return s
}
func (s *TermvectorsService) Preference(preference string) *TermvectorsService {
	s.preference = preference
	return s
}
func (s *TermvectorsService) Realtime(realtime bool) *TermvectorsService {
	s.realtime = &realtime
	return s
}
func (s *TermvectorsService) Routing(routing string) *TermvectorsService {
	s.routing = routing
	return s
}
func (s *TermvectorsService) TermStatistics(termStatistics bool) *TermvectorsService {
	s.termStatistics = &termStatistics
	return s
}
func (s *TermvectorsService) Version(version interface{}) *TermvectorsService {
	s.version = version
	return s
}
func (s *TermvectorsService) VersionType(versionType string) *TermvectorsService {
	s.versionType = versionType
	return s
}
func (s *TermvectorsService) Pretty(pretty bool) *TermvectorsService {
	s.pretty = pretty
	return s
}
func (s *TermvectorsService) BodyJson(body interface{}) *TermvectorsService {
	s.bodyJson = body
	return s
}
func (s *TermvectorsService) BodyString(body string) *TermvectorsService {
	s.bodyString = body
	return s
}
func (s *TermvectorsService) buildURL() (string, url.Values, error) {
	var pathParam = map[string]string{
		"index": s.index,
		"type":  s.typ,
	}
	var path string
	var err error
	if s.id != "" {
		pathParam["id"] = s.id
		path, err = uritemplates.Expand("/{index}/{type}/{id}/_termvectors", pathParam)
	} else {
		path, err = uritemplates.Expand("/{index}/{type}/_termvectors", pathParam)
	}
	if err != nil {
		return "", url.Values{}, err
	}
	params := url.Values{}
	if s.pretty {
		params.Set("pretty", "1")
	}
	if s.dfs != nil {
		params.Set("dfs", fmt.Sprintf("%v", *s.dfs))
	}
	if s.fieldStatistics != nil {
		params.Set("field_statistics", fmt.Sprintf("%v", *s.fieldStatistics))
	}
	if len(s.fields) > 0 {
		params.Set("fields", strings.Join(s.fields, ","))
	}
	if s.offsets != nil {
		params.Set("offsets", fmt.Sprintf("%v", *s.offsets))
	}
	if s.parent != "" {
		params.Set("parent", s.parent)
	}
	if s.payloads != nil {
		params.Set("payloads", fmt.Sprintf("%v", *s.payloads))
	}
	if s.positions != nil {
		params.Set("positions", fmt.Sprintf("%v", *s.positions))
	}
	if s.preference != "" {
		params.Set("preference", s.preference)
	}
	if s.realtime != nil {
		params.Set("realtime", fmt.Sprintf("%v", *s.realtime))
	}
	if s.routing != "" {
		params.Set("routing", s.routing)
	}
	if s.termStatistics != nil {
		params.Set("term_statistics", fmt.Sprintf("%v", *s.termStatistics))
	}
	if s.version != nil {
		params.Set("version", fmt.Sprintf("%v", s.version))
	}
	if s.versionType != "" {
		params.Set("version_type", s.versionType)
	}
	return path, params, nil
}
func (s *TermvectorsService) Validate() error {
	var invalid []string
	if s.index == "" {
		invalid = append(invalid, "Index")
	}
	if s.typ == "" {
		invalid = append(invalid, "Type")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}
func (s *TermvectorsService) Do() (*TermvectorsResponse, 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 if s.bodyString != "" {
		body = s.bodyString
	} else {
		data := make(map[string]interface{})
		if s.doc != nil {
			data["doc"] = s.doc
		}
		if len(s.perFieldAnalyzer) > 0 {
			data["per_field_analyzer"] = s.perFieldAnalyzer
		}
		if s.filter != nil {
			src, err := s.filter.Source()
			if err != nil {
				return nil, err
			}
			data["filter"] = src
		}
		if len(data) > 0 {
			body = data
		}
	}
	res, err := s.client.PerformRequest("GET", path, params, body)
	if err != nil {
		return nil, err
	}
	ret := new(TermvectorsResponse)
	if err := s.client.decoder.Decode(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
type TermvectorsFilterSettings struct {
	maxNumTerms   *int64
	minTermFreq   *int64
	maxTermFreq   *int64
	minDocFreq    *int64
	maxDocFreq    *int64
	minWordLength *int64
	maxWordLength *int64
}
func NewTermvectorsFilterSettings() *TermvectorsFilterSettings {
	return &TermvectorsFilterSettings{}
}
func (fs *TermvectorsFilterSettings) MaxNumTerms(value int64) *TermvectorsFilterSettings {
	fs.maxNumTerms = &value
	return fs
}
func (fs *TermvectorsFilterSettings) MinTermFreq(value int64) *TermvectorsFilterSettings {
	fs.minTermFreq = &value
	return fs
}
func (fs *TermvectorsFilterSettings) MaxTermFreq(value int64) *TermvectorsFilterSettings {
	fs.maxTermFreq = &value
	return fs
}
func (fs *TermvectorsFilterSettings) MinDocFreq(value int64) *TermvectorsFilterSettings {
	fs.minDocFreq = &value
	return fs
}