func (a *CompositeAggregationDateHistogramValuesSource) Source() (interface{}, error) {
	source := make(map[string]interface{})
	name := make(map[string]interface{})
	source[a.name] = name
	values := make(map[string]interface{})
	name["date_histogram"] = values
	if a.field != "" {
		values["field"] = a.field
	}
	if a.script != nil {
		src, err := a.script.Source()
		if err != nil {
			return nil, err
		}
		values["script"] = src
	}
	if a.missing != nil {
		values["missing"] = a.missing
	}
	if a.missingBucket != nil {
		values["missing_bucket"] = *a.missingBucket
	}
	if a.valueType != "" {
		values["value_type"] = a.valueType
	}
	if a.order != "" {
		values["order"] = a.order
	}
	if a.format != "" {
		values["format"] = a.format
	}
	if v := a.interval; v != nil {
		values["interval"] = v
	}
	if v := a.fixedInterval; v != nil {
		values["fixed_interval"] = v
	}
	if v := a.calendarInterval; v != nil {
		values["calendar_interval"] = v
	}
	if a.timeZone != "" {
		values["time_zone"] = a.timeZone
	}
	return source, nil
}
Source returns the serializable JSON for this values source.
package elastic
type CompositeAggregation struct {
	after           map[string]interface{}
	size            *int
	sources         []CompositeAggregationValuesSource
	subAggregations map[string]Aggregation
	meta            map[string]interface{}
}
func NewCompositeAggregation() *CompositeAggregation {
	return &CompositeAggregation{
		sources:         make([]CompositeAggregationValuesSource, 0),
		subAggregations: make(map[string]Aggregation),
	}
}
func (a *CompositeAggregation) Size(size int) *CompositeAggregation {
	a.size = &size
	return a
}
func (a *CompositeAggregation) AggregateAfter(after map[string]interface{}) *CompositeAggregation {
	a.after = after
	return a
}
func (a *CompositeAggregation) Sources(sources ...CompositeAggregationValuesSource) *CompositeAggregation {
	a.sources = append(a.sources, sources...)
	return a
}
func (a *CompositeAggregation) SubAggregation(name string, subAggregation Aggregation) *CompositeAggregation {
	a.subAggregations[name] = subAggregation
	return a
}
func (a *CompositeAggregation) Meta(metaData map[string]interface{}) *CompositeAggregation {
	a.meta = metaData
	return a
}
func (a *CompositeAggregation) Source() (interface{}, error) {
	source := make(map[string]interface{})
	opts := make(map[string]interface{})
	source["composite"] = opts
	sources := make([]interface{}, len(a.sources))
	for i, s := range a.sources {
		src, err := s.Source()
		if err != nil {
			return nil, err
		}
		sources[i] = src
	}
	opts["sources"] = sources
	if a.size != nil {
		opts["size"] = *a.size
	}
	if a.after != nil {
		opts["after"] = a.after
	}
	if len(a.subAggregations) > 0 {
		aggsMap := make(map[string]interface{})
		source["aggregations"] = aggsMap
		for name, aggregate := range a.subAggregations {
			src, err := aggregate.Source()
			if err != nil {
				return nil, err
			}
			aggsMap[name] = src
		}
	}
	if len(a.meta) > 0 {
		source["meta"] = a.meta
	}
	return source, nil
}
type CompositeAggregationValuesSource interface {
	Source() (interface{}, error)
}
type CompositeAggregationTermsValuesSource struct {
	name          string
	field         string
	script        *Script
	valueType     string
	missing       interface{}
	missingBucket *bool
	order         string
}
func NewCompositeAggregationTermsValuesSource(name string) *CompositeAggregationTermsValuesSource {
	return &CompositeAggregationTermsValuesSource{
		name: name,
	}
}
func (a *CompositeAggregationTermsValuesSource) Field(field string) *CompositeAggregationTermsValuesSource {
	a.field = field
	return a
}
func (a *CompositeAggregationTermsValuesSource) Script(script *Script) *CompositeAggregationTermsValuesSource {
	a.script = script
	return a
}
func (a *CompositeAggregationTermsValuesSource) ValueType(valueType string) *CompositeAggregationTermsValuesSource {
	a.valueType = valueType
	return a
}
func (a *CompositeAggregationTermsValuesSource) Order(order string) *CompositeAggregationTermsValuesSource {
	a.order = order
	return a
}
func (a *CompositeAggregationTermsValuesSource) Asc() *CompositeAggregationTermsValuesSource {
	a.order = "asc"
	return a
}
func (a *CompositeAggregationTermsValuesSource) Desc() *CompositeAggregationTermsValuesSource {
	a.order = "desc"
	return a
}
func (a *CompositeAggregationTermsValuesSource) Missing(missing interface{}) *CompositeAggregationTermsValuesSource {
	a.missing = missing
	return a
}
func (a *CompositeAggregationTermsValuesSource) MissingBucket(missingBucket bool) *CompositeAggregationTermsValuesSource {
	a.missingBucket = &missingBucket
	return a
}
func (a *CompositeAggregationTermsValuesSource) Source() (interface{}, error) {
	source := make(map[string]interface{})
	name := make(map[string]interface{})
	source[a.name] = name
	values := make(map[string]interface{})
	name["terms"] = values
	if a.field != "" {
		values["field"] = a.field
	}
	if a.script != nil {
		src, err := a.script.Source()
		if err != nil {
			return nil, err
		}
		values["script"] = src
	}
	if a.missing != nil {
		values["missing"] = a.missing
	}
	if a.missingBucket != nil {
		values["missing_bucket"] = *a.missingBucket
	}
	if a.valueType != "" {
		values["value_type"] = a.valueType
	}
	if a.order != "" {
		values["order"] = a.order
	}
	return source, nil
}
type CompositeAggregationHistogramValuesSource struct {
	name          string
	field         string
	script        *Script
	valueType     string
	missing       interface{}
	missingBucket *bool
	order         string
	interval      float64
}
func NewCompositeAggregationHistogramValuesSource(name string, interval float64) *CompositeAggregationHistogramValuesSource {
	return &CompositeAggregationHistogramValuesSource{
		name:     name,
		interval: interval,
	}
}
func (a *CompositeAggregationHistogramValuesSource) Field(field string) *CompositeAggregationHistogramValuesSource {
	a.field = field
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Script(script *Script) *CompositeAggregationHistogramValuesSource {
	a.script = script
	return a
}
func (a *CompositeAggregationHistogramValuesSource) ValueType(valueType string) *CompositeAggregationHistogramValuesSource {
	a.valueType = valueType
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Missing(missing interface{}) *CompositeAggregationHistogramValuesSource {
	a.missing = missing
	return a
}
func (a *CompositeAggregationHistogramValuesSource) MissingBucket(missingBucket bool) *CompositeAggregationHistogramValuesSource {
	a.missingBucket = &missingBucket
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Order(order string) *CompositeAggregationHistogramValuesSource {
	a.order = order
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Asc() *CompositeAggregationHistogramValuesSource {
	a.order = "asc"
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Desc() *CompositeAggregationHistogramValuesSource {
	a.order = "desc"
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Interval(interval float64) *CompositeAggregationHistogramValuesSource {
	a.interval = interval
	return a
}
func (a *CompositeAggregationHistogramValuesSource) Source() (interface{}, error) {
	source := make(map[string]interface{})
	name := make(map[string]interface{})
	source[a.name] = name
	values := make(map[string]interface{})
	name["histogram"] = values
	if a.field != "" {
		values["field"] = a.field
	}
	if a.script != nil {
		src, err := a.script.Source()
		if err != nil {
			return nil, err
		}
		values["script"] = src
	}
	if a.missing != nil {
		values["missing"] = a.missing
	}
	if a.missingBucket != nil {
		values["missing_bucket"] = *a.missingBucket
	}
	if a.valueType != "" {
		values["value_type"] = a.valueType
	}
	if a.order != "" {
		values["order"] = a.order
	}
	values["interval"] = a.interval
	return source, nil
}
type CompositeAggregationDateHistogramValuesSource struct {
	name             string
	field            string
	script           *Script
	valueType        string
	missing          interface{}
	missingBucket    *bool
	order            string
	interval         interface{}
	fixedInterval    interface{}
	calendarInterval interface{}
	format           string
	timeZone         string
}
func NewCompositeAggregationDateHistogramValuesSource(name string) *CompositeAggregationDateHistogramValuesSource {
	return &CompositeAggregationDateHistogramValuesSource{
		name: name,
	}
}
func (a *CompositeAggregationDateHistogramValuesSource) Field(field string) *CompositeAggregationDateHistogramValuesSource {
	a.field = field
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Script(script *Script) *CompositeAggregationDateHistogramValuesSource {
	a.script = script
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) ValueType(valueType string) *CompositeAggregationDateHistogramValuesSource {
	a.valueType = valueType
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Missing(missing interface{}) *CompositeAggregationDateHistogramValuesSource {
	a.missing = missing
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) MissingBucket(missingBucket bool) *CompositeAggregationDateHistogramValuesSource {
	a.missingBucket = &missingBucket
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Order(order string) *CompositeAggregationDateHistogramValuesSource {
	a.order = order
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Asc() *CompositeAggregationDateHistogramValuesSource {
	a.order = "asc"
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Desc() *CompositeAggregationDateHistogramValuesSource {
	a.order = "desc"
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Interval(interval interface{}) *CompositeAggregationDateHistogramValuesSource {
	a.interval = interval
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) FixedInterval(fixedInterval interface{}) *CompositeAggregationDateHistogramValuesSource {
	a.fixedInterval = fixedInterval
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) CalendarInterval(calendarInterval interface{}) *CompositeAggregationDateHistogramValuesSource {
	a.calendarInterval = calendarInterval
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) Format(format string) *CompositeAggregationDateHistogramValuesSource {
	a.format = format
	return a
}
func (a *CompositeAggregationDateHistogramValuesSource) TimeZone(timeZone string) *CompositeAggregationDateHistogramValuesSource {
	a.timeZone = timeZone
	return a
}