func (s ScriptSort) SortMode(sortMode string) ScriptSort {
	s.sortMode = &sortMode
	return s
}
SortMode specifies what values to pick in case a document contains
multiple values for the targeted sort field. Possible values are:
min or max.
package elastic
import "errors"
type Sorter interface {
	Source() (interface{}, error)
}
type SortInfo struct {
	Sorter
	Field          string
	Ascending      bool
	Missing        interface{}
	IgnoreUnmapped *bool
	SortMode       string
	NestedFilter   Query
	NestedPath     string
}
func (info SortInfo) Source() (interface{}, error) {
	prop := make(map[string]interface{})
	if info.Ascending {
		prop["order"] = "asc"
	} else {
		prop["order"] = "desc"
	}
	if info.Missing != nil {
		prop["missing"] = info.Missing
	}
	if info.IgnoreUnmapped != nil {
		prop["ignore_unmapped"] = *info.IgnoreUnmapped
	}
	if info.SortMode != "" {
		prop["mode"] = info.SortMode
	}
	if info.NestedFilter != nil {
		src, err := info.NestedFilter.Source()
		if err != nil {
			return nil, err
		}
		prop["nested_filter"] = src
	}
	if info.NestedPath != "" {
		prop["nested_path"] = info.NestedPath
	}
	source := make(map[string]interface{})
	source[info.Field] = prop
	return source, nil
}
type ScoreSort struct {
	Sorter
	ascending bool
}
func NewScoreSort() ScoreSort {
	return ScoreSort{ascending: false}  
}
func (s ScoreSort) Order(ascending bool) ScoreSort {
	s.ascending = ascending
	return s
}
func (s ScoreSort) Asc() ScoreSort {
	s.ascending = true
	return s
}
func (s ScoreSort) Desc() ScoreSort {
	s.ascending = false
	return s
}
func (s ScoreSort) Source() (interface{}, error) {
	source := make(map[string]interface{})
	x := make(map[string]interface{})
	source["_score"] = x
	if s.ascending {
		x["reverse"] = true
	}
	return source, nil
}
type FieldSort struct {
	Sorter
	fieldName      string
	ascending      bool
	missing        interface{}
	ignoreUnmapped *bool
	unmappedType   *string
	sortMode       *string
	nestedFilter   Query
	nestedPath     *string
}
func NewFieldSort(fieldName string) FieldSort {
	return FieldSort{
		fieldName: fieldName,
		ascending: true,
	}
}
func (s FieldSort) FieldName(fieldName string) FieldSort {
	s.fieldName = fieldName
	return s
}
func (s FieldSort) Order(ascending bool) FieldSort {
	s.ascending = ascending
	return s
}
func (s FieldSort) Asc() FieldSort {
	s.ascending = true
	return s
}
func (s FieldSort) Desc() FieldSort {
	s.ascending = false
	return s
}
func (s FieldSort) Missing(missing interface{}) FieldSort {
	s.missing = missing
	return s
}
func (s FieldSort) IgnoreUnmapped(ignoreUnmapped bool) FieldSort {
	s.ignoreUnmapped = &ignoreUnmapped
	return s
}
func (s FieldSort) UnmappedType(typ string) FieldSort {
	s.unmappedType = &typ
	return s
}
func (s FieldSort) SortMode(sortMode string) FieldSort {
	s.sortMode = &sortMode
	return s
}
func (s FieldSort) NestedFilter(nestedFilter Query) FieldSort {
	s.nestedFilter = nestedFilter
	return s
}
func (s FieldSort) NestedPath(nestedPath string) FieldSort {
	s.nestedPath = &nestedPath
	return s
}
func (s FieldSort) Source() (interface{}, error) {
	source := make(map[string]interface{})
	x := make(map[string]interface{})
	source[s.fieldName] = x
	if s.ascending {
		x["order"] = "asc"
	} else {
		x["order"] = "desc"
	}
	if s.missing != nil {
		x["missing"] = s.missing
	}
	if s.ignoreUnmapped != nil {
		x["ignore_unmapped"] = *s.ignoreUnmapped
	}
	if s.unmappedType != nil {
		x["unmapped_type"] = *s.unmappedType
	}
	if s.sortMode != nil {
		x["mode"] = *s.sortMode
	}
	if s.nestedFilter != nil {
		src, err := s.nestedFilter.Source()
		if err != nil {
			return nil, err
		}
		x["nested_filter"] = src
	}
	if s.nestedPath != nil {
		x["nested_path"] = *s.nestedPath
	}
	return source, nil
}
type GeoDistanceSort struct {
	Sorter
	fieldName    string
	points       []*GeoPoint
	geohashes    []string
	geoDistance  *string
	unit         string
	ascending    bool
	sortMode     *string
	nestedFilter Query
	nestedPath   *string
}
func NewGeoDistanceSort(fieldName string) GeoDistanceSort {
	return GeoDistanceSort{
		fieldName: fieldName,
		points:    make([]*GeoPoint, 0),
		geohashes: make([]string, 0),
		ascending: true,
	}
}
func (s GeoDistanceSort) FieldName(fieldName string) GeoDistanceSort {
	s.fieldName = fieldName
	return s
}
func (s GeoDistanceSort) Order(ascending bool) GeoDistanceSort {
	s.ascending = ascending
	return s
}
func (s GeoDistanceSort) Asc() GeoDistanceSort {
	s.ascending = true
	return s
}
func (s GeoDistanceSort) Desc() GeoDistanceSort {
	s.ascending = false
	return s
}
func (s GeoDistanceSort) Point(lat, lon float64) GeoDistanceSort {
	s.points = append(s.points, GeoPointFromLatLon(lat, lon))
	return s
}
func (s GeoDistanceSort) Points(points ...*GeoPoint) GeoDistanceSort {
	s.points = append(s.points, points...)
	return s
}
func (s GeoDistanceSort) GeoHashes(geohashes ...string) GeoDistanceSort {
	s.geohashes = append(s.geohashes, geohashes...)
	return s
}
func (s GeoDistanceSort) GeoDistance(geoDistance string) GeoDistanceSort {
	s.geoDistance = &geoDistance
	return s
}
func (s GeoDistanceSort) Unit(unit string) GeoDistanceSort {
	s.unit = unit
	return s
}
func (s GeoDistanceSort) SortMode(sortMode string) GeoDistanceSort {
	s.sortMode = &sortMode
	return s
}
func (s GeoDistanceSort) NestedFilter(nestedFilter Query) GeoDistanceSort {
	s.nestedFilter = nestedFilter
	return s
}
func (s GeoDistanceSort) NestedPath(nestedPath string) GeoDistanceSort {
	s.nestedPath = &nestedPath
	return s
}
func (s GeoDistanceSort) Source() (interface{}, error) {
	source := make(map[string]interface{})
	x := make(map[string]interface{})
	source["_geo_distance"] = x
	ptarr := make([]interface{}, 0)
	for _, pt := range s.points {
		ptarr = append(ptarr, pt.Source())
	}
	for _, geohash := range s.geohashes {
		ptarr = append(ptarr, geohash)
	}
	x[s.fieldName] = ptarr
	if s.unit != "" {
		x["unit"] = s.unit
	}
	if s.geoDistance != nil {
		x["distance_type"] = *s.geoDistance
	}
	if !s.ascending {
		x["reverse"] = true
	}
	if s.sortMode != nil {
		x["mode"] = *s.sortMode
	}
	if s.nestedFilter != nil {
		src, err := s.nestedFilter.Source()
		if err != nil {
			return nil, err
		}
		x["nested_filter"] = src
	}
	if s.nestedPath != nil {
		x["nested_path"] = *s.nestedPath
	}
	return source, nil
}
type ScriptSort struct {
	Sorter
	script       *Script
	typ          string
	ascending    bool
	sortMode     *string
	nestedFilter Query
	nestedPath   *string
}
func NewScriptSort(script *Script, typ string) ScriptSort {
	return ScriptSort{
		script:    script,
		typ:       typ,
		ascending: true,
	}
}
func (s ScriptSort) Type(typ string) ScriptSort {
	s.typ = typ
	return s
}
func (s ScriptSort) Order(ascending bool) ScriptSort {
	s.ascending = ascending
	return s
}
func (s ScriptSort) Asc() ScriptSort {
	s.ascending = true
	return s
}
func (s ScriptSort) Desc() ScriptSort {
	s.ascending = false
	return s
}