func (a *TermsAggregation) CollectionMode(collectionMode string) *TermsAggregation {
	a.collectionMode = collectionMode
	return a
}
Collection mode can be depth_first or breadth_first as of 1.4.0.
package elastic
type TermsAggregation struct {
	field           string
	script          *Script
	missing         interface{}
	subAggregations map[string]Aggregation
	meta            map[string]interface{}
	size                  *int
	shardSize             *int
	requiredSize          *int
	minDocCount           *int
	shardMinDocCount      *int
	valueType             string
	order                 string
	orderAsc              bool
	includePattern        string
	includeFlags          *int
	excludePattern        string
	excludeFlags          *int
	executionHint         string
	collectionMode        string
	showTermDocCountError *bool
	includeTerms          []string
	excludeTerms          []string
}
func NewTermsAggregation() *TermsAggregation {
	return &TermsAggregation{
		subAggregations: make(map[string]Aggregation, 0),
		includeTerms:    make([]string, 0),
		excludeTerms:    make([]string, 0),
	}
}
func (a *TermsAggregation) Field(field string) *TermsAggregation {
	a.field = field
	return a
}
func (a *TermsAggregation) Script(script *Script) *TermsAggregation {
	a.script = script
	return a
}
func (a *TermsAggregation) Missing(missing interface{}) *TermsAggregation {
	a.missing = missing
	return a
}
func (a *TermsAggregation) SubAggregation(name string, subAggregation Aggregation) *TermsAggregation {
	a.subAggregations[name] = subAggregation
	return a
}
func (a *TermsAggregation) Meta(metaData map[string]interface{}) *TermsAggregation {
	a.meta = metaData
	return a
}
func (a *TermsAggregation) Size(size int) *TermsAggregation {
	a.size = &size
	return a
}
func (a *TermsAggregation) RequiredSize(requiredSize int) *TermsAggregation {
	a.requiredSize = &requiredSize
	return a
}
func (a *TermsAggregation) ShardSize(shardSize int) *TermsAggregation {
	a.shardSize = &shardSize
	return a
}
func (a *TermsAggregation) MinDocCount(minDocCount int) *TermsAggregation {
	a.minDocCount = &minDocCount
	return a
}
func (a *TermsAggregation) ShardMinDocCount(shardMinDocCount int) *TermsAggregation {
	a.shardMinDocCount = &shardMinDocCount
	return a
}
func (a *TermsAggregation) Include(regexp string) *TermsAggregation {
	a.includePattern = regexp
	return a
}
func (a *TermsAggregation) IncludeWithFlags(regexp string, flags int) *TermsAggregation {
	a.includePattern = regexp
	a.includeFlags = &flags
	return a
}
func (a *TermsAggregation) Exclude(regexp string) *TermsAggregation {
	a.excludePattern = regexp
	return a
}
func (a *TermsAggregation) ExcludeWithFlags(regexp string, flags int) *TermsAggregation {
	a.excludePattern = regexp
	a.excludeFlags = &flags
	return a
}
func (a *TermsAggregation) ValueType(valueType string) *TermsAggregation {
	a.valueType = valueType
	return a
}
func (a *TermsAggregation) Order(order string, asc bool) *TermsAggregation {
	a.order = order
	a.orderAsc = asc
	return a
}
func (a *TermsAggregation) OrderByCount(asc bool) *TermsAggregation {
	a.order = "_count"
	a.orderAsc = asc
	return a
}
func (a *TermsAggregation) OrderByCountAsc() *TermsAggregation {
	return a.OrderByCount(true)
}
func (a *TermsAggregation) OrderByCountDesc() *TermsAggregation {
	return a.OrderByCount(false)
}
func (a *TermsAggregation) OrderByTerm(asc bool) *TermsAggregation {
	a.order = "_term"
	a.orderAsc = asc
	return a
}
func (a *TermsAggregation) OrderByTermAsc() *TermsAggregation {
	return a.OrderByTerm(true)
}
func (a *TermsAggregation) OrderByTermDesc() *TermsAggregation {
	return a.OrderByTerm(false)
}
func (a *TermsAggregation) OrderByAggregation(aggName string, asc bool) *TermsAggregation {
	a.order = aggName
	a.orderAsc = asc
	return a
}
func (a *TermsAggregation) OrderByAggregationAndMetric(aggName, metric string, asc bool) *TermsAggregation {
	a.order = aggName + "." + metric
	a.orderAsc = asc
	return a
}
func (a *TermsAggregation) ExecutionHint(hint string) *TermsAggregation {
	a.executionHint = hint
	return a
}