func (o *FuzzyCompletionSuggesterOptions) MaxDeterminizedStates(max int) *FuzzyCompletionSuggesterOptions {
	o.maxDeterminizedStates = &max
	return o
}
MaxDeterminizedStates is currently undocumented in Elasticsearch. It represents
the maximum automaton states allowed for fuzzy expansion.
package elastic
import "errors"
type CompletionSuggester struct {
	Suggester
	name           string
	text           string
	prefix         string
	regex          string
	field          string
	analyzer       string
	size           *int
	shardSize      *int
	contextQueries []SuggesterContextQuery
	payload        interface{}
	fuzzyOptions   *FuzzyCompletionSuggesterOptions
	regexOptions   *RegexCompletionSuggesterOptions
	skipDuplicates *bool
}
func NewCompletionSuggester(name string) *CompletionSuggester {
	return &CompletionSuggester{
		name: name,
	}
}
func (q *CompletionSuggester) Name() string {
	return q.name
}
func (q *CompletionSuggester) Text(text string) *CompletionSuggester {
	q.text = text
	return q
}
func (q *CompletionSuggester) Prefix(prefix string) *CompletionSuggester {
	q.prefix = prefix
	return q
}
func (q *CompletionSuggester) PrefixWithEditDistance(prefix string, editDistance interface{}) *CompletionSuggester {
	q.prefix = prefix
	q.fuzzyOptions = NewFuzzyCompletionSuggesterOptions().EditDistance(editDistance)
	return q
}
func (q *CompletionSuggester) PrefixWithOptions(prefix string, options *FuzzyCompletionSuggesterOptions) *CompletionSuggester {
	q.prefix = prefix
	q.fuzzyOptions = options
	return q
}
func (q *CompletionSuggester) FuzzyOptions(options *FuzzyCompletionSuggesterOptions) *CompletionSuggester {
	q.fuzzyOptions = options
	return q
}
func (q *CompletionSuggester) Fuzziness(fuzziness interface{}) *CompletionSuggester {
	if q.fuzzyOptions == nil {
		q.fuzzyOptions = NewFuzzyCompletionSuggesterOptions()
	}
	q.fuzzyOptions = q.fuzzyOptions.EditDistance(fuzziness)
	return q
}
func (q *CompletionSuggester) Regex(regex string) *CompletionSuggester {
	q.regex = regex
	return q
}
func (q *CompletionSuggester) RegexWithOptions(regex string, options *RegexCompletionSuggesterOptions) *CompletionSuggester {
	q.regex = regex
	q.regexOptions = options
	return q
}
func (q *CompletionSuggester) RegexOptions(options *RegexCompletionSuggesterOptions) *CompletionSuggester {
	q.regexOptions = options
	return q
}
func (q *CompletionSuggester) SkipDuplicates(skipDuplicates bool) *CompletionSuggester {
	q.skipDuplicates = &skipDuplicates
	return q
}
func (q *CompletionSuggester) Field(field string) *CompletionSuggester {
	q.field = field
	return q
}
func (q *CompletionSuggester) Analyzer(analyzer string) *CompletionSuggester {
	q.analyzer = analyzer
	return q
}
func (q *CompletionSuggester) Size(size int) *CompletionSuggester {
	q.size = &size
	return q
}
func (q *CompletionSuggester) ShardSize(shardSize int) *CompletionSuggester {
	q.shardSize = &shardSize
	return q
}
func (q *CompletionSuggester) ContextQuery(query SuggesterContextQuery) *CompletionSuggester {
	q.contextQueries = append(q.contextQueries, query)
	return q
}
func (q *CompletionSuggester) ContextQueries(queries ...SuggesterContextQuery) *CompletionSuggester {
	q.contextQueries = append(q.contextQueries, queries...)
	return q
}
type completionSuggesterRequest struct {
	Text       string      `json:"text,omitempty"`
	Prefix     string      `json:"prefix,omitempty"`
	Regex      string      `json:"regex,omitempty"`
	Completion interface{} `json:"completion,omitempty"`
}
func (q *CompletionSuggester) Source(includeName bool) (interface{}, error) {
	cs := &completionSuggesterRequest{}
	if q.text != "" {
		cs.Text = q.text
	}
	if q.prefix != "" {
		cs.Prefix = q.prefix
	}
	if q.regex != "" {
		cs.Regex = q.regex
	}
	suggester := make(map[string]interface{})
	cs.Completion = suggester
	if q.analyzer != "" {
		suggester["analyzer"] = q.analyzer
	}
	if q.field != "" {
		suggester["field"] = q.field
	}
	if q.size != nil {
		suggester["size"] = *q.size
	}
	if q.shardSize != nil {
		suggester["shard_size"] = *q.shardSize
	}
	switch len(q.contextQueries) {
	case 0:
	case 1:
		src, err := q.contextQueries[0].Source()
		if err != nil {
			return nil, err
		}
		suggester["contexts"] = src
	default:
		ctxq := make(map[string]interface{})
		for _, query := range q.contextQueries {
			src, err := query.Source()
			if err != nil {
				return nil, err
			}
			m, ok := src.(map[string]interface{})
			if !ok {
				return nil, errors.New("elastic: context query is not a map")
			}
			for k, v := range m {
				ctxq[k] = v
			}
		}
		suggester["contexts"] = ctxq
	}
	if q.fuzzyOptions != nil {
		src, err := q.fuzzyOptions.Source()
		if err != nil {
			return nil, err
		}
		suggester["fuzzy"] = src
	}
	if q.regexOptions != nil {
		src, err := q.regexOptions.Source()
		if err != nil {
			return nil, err
		}
		suggester["regex"] = src
	}
	if q.skipDuplicates != nil {
		suggester["skip_duplicates"] = *q.skipDuplicates
	}
	if !includeName {
		return cs, nil
	}
	source := make(map[string]interface{})
	source[q.name] = cs
	return source, nil
}
type FuzzyCompletionSuggesterOptions struct {
	editDistance          interface{}
	transpositions        *bool
	minLength             *int
	prefixLength          *int
	unicodeAware          *bool
	maxDeterminizedStates *int
}
func NewFuzzyCompletionSuggesterOptions() *FuzzyCompletionSuggesterOptions {
	return &FuzzyCompletionSuggesterOptions{}
}
func (o *FuzzyCompletionSuggesterOptions) EditDistance(editDistance interface{}) *FuzzyCompletionSuggesterOptions {
	o.editDistance = editDistance
	return o
}
func (o *FuzzyCompletionSuggesterOptions) Transpositions(transpositions bool) *FuzzyCompletionSuggesterOptions {
	o.transpositions = &transpositions
	return o
}
func (o *FuzzyCompletionSuggesterOptions) MinLength(minLength int) *FuzzyCompletionSuggesterOptions {
	o.minLength = &minLength
	return o
}
func (o *FuzzyCompletionSuggesterOptions) PrefixLength(prefixLength int) *FuzzyCompletionSuggesterOptions {
	o.prefixLength = &prefixLength
	return o
}
func (o *FuzzyCompletionSuggesterOptions) UnicodeAware(unicodeAware bool) *FuzzyCompletionSuggesterOptions {
	o.unicodeAware = &unicodeAware
	return o
}