// PrettyMap sorts a Map by its keys and returns a pretty-printed string version.
421907
func PrettyMap(m Map) string {
	var keys []string
	for k, _ := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	var values []string
	for _, k := range keys {
		values = append(values, fmt.Sprintf("%q: %s", k, m[k]))
	}
	r := strings.Join(values, "\n")
	return fmt.Sprintf("%s", r)
}
1044806
func (s *IndicesDeleteService) Pretty(pretty bool) *IndicesDeleteService {
	s.pretty = pretty
	return s
}
407255
func (s *IndicesExistsTemplateService) Pretty(pretty bool) *IndicesExistsTemplateService {
	s.pretty = pretty
	return s
}
707960
func stringKeysFromMap(m interface{}) (keys []string) {
	for _, k := range reflect.ValueOf(m).MapKeys() {
		keys = append(keys, k.String())
	}
	return
}
833636
func (s *ValidateService) Pretty(pretty bool) *ValidateService {
	s.pretty = pretty
	return s
}
388900
func (s *SearchShardsService) Pretty(pretty bool) *SearchShardsService {
	s.pretty = pretty
	return s
}
509238
func (mmap MarshalMap) StringMap(key string) (map[string]string, error) {
	val, exists := mmap.Value(key)
	if !exists {
		return nil, fmt.Errorf(`"%s" is not set`, key)
	}

	switch val.(type) {
	case map[string]string:
		return val.(map[string]string), nil

	default:
		valueMeta := reflect.ValueOf(val)
		if valueMeta.Kind() != reflect.Map {
			return nil, fmt.Errorf(`"%s" is expected to be a map[string]string but is %T`, key, val)
		}

		result := make(map[string]string)
		for _, keyMeta := range valueMeta.MapKeys() {
			strKey, isString := keyMeta.Interface().(string)
			if !isString {
				return nil, fmt.Errorf(`"%s" is expected to be a map[string]string. Key is not a string`, key)
			}

			value := valueMeta.MapIndex(keyMeta)
			strValue, isString := value.Interface().(string)
			if !isString {
				return nil, fmt.Errorf(`"%s" is expected to be a map[string]string. Value is not a string`, key)
			}

			result[strKey] = strValue
		}

		return result, nil
	}
}
394619
func (s *ReindexService) Pretty(pretty bool) *ReindexService {
	s.pretty = pretty
	return s
}
1290739
func formatMap(m map[string]string) string {
	var l string
	for key, value := range m {
		l += key + "=" + fmt.Sprintf("%q", value) + "\n"
	}
	return l
}
982182
func (s *CountService) Pretty(pretty bool) *CountService {
	s.pretty = pretty
	return s
}
791664
func PrettyPrint(v interface{}) string {
	value := reflect.ValueOf(v)
	switch value.Kind() {
	case reflect.Struct:
		str := fullName(value.Type()) + "{\n"
		for i := 0; i < value.NumField(); i++ {
			l := string(value.Type().Field(i).Name[0])
			if strings.ToUpper(l) == l {
				str += value.Type().Field(i).Name + ": "
				str += PrettyPrint(value.Field(i).Interface())
				str += ",\n"
			}
		}
		str += "}"
		return str
	case reflect.Map:
		str := "map[" + fullName(value.Type().Key()) + "]" + fullName(value.Type().Elem()) + "{\n"
		for _, k := range value.MapKeys() {
			str += "\"" + k.String() + "\": "
			str += PrettyPrint(value.MapIndex(k).Interface())
			str += ",\n"
		}
		str += "}"
		return str
	case reflect.Ptr:
		if e := value.Elem(); e.IsValid() {
			return "&" + PrettyPrint(e.Interface())
		}
		return "nil"
	case reflect.Slice:
		str := "[]" + fullName(value.Type().Elem()) + "{\n"
		for i := 0; i < value.Len(); i++ {
			str += PrettyPrint(value.Index(i).Interface())
			str += ",\n"
		}
		str += "}"
		return str
	default:
		return fmt.Sprintf("%#v", v)
	}
}
947134
func (s *IndicesPutMappingService) Pretty(pretty bool) *IndicesPutMappingService {
	s.pretty = pretty
	return s
}
1267343
func (s *ExplainService) Pretty(pretty bool) *ExplainService {
	s.pretty = pretty
	return s
}
1167099
func KeysOfMap(m map[string]string) []string {
	keys := make(sort.StringSlice, len(m))
	i := 0
	for key, _ := range m {
		keys[i] = key
		i++
	}

	keys.Sort()
	return []string(keys)
}
397389
func (s *IndicesSegmentsService) Pretty(pretty bool) *IndicesSegmentsService {
	s.pretty = pretty
	return s
}
24189
func PrettyFormat(i interface{}) string {
	var out bytes.Buffer
	PrettyPrintTo(&out, i, false)
	return out.String()
}
171327
func (s *SearchService) Pretty(pretty bool) *SearchService {
	s.pretty = pretty
	return s
}