// Terms returns which languages the source repository was
// built with
1307
func (info *SourceRepositoryInfo) Terms() []string {
	terms := []string{}
	for i := range info.Types {
		terms = append(terms, info.Types[i].Term())
	}
	return terms
}
430079
func (t Term) Or(args ...interface{}) Term {
	return constructMethodTerm(t, "Or", p.Term_OR, args, map[string]interface{}{})
}
181496
func Do(args ...interface{}) Term {
	newArgs := []interface{}{}
	newArgs = append(newArgs, funcWrap(args[len(args)-1]))
	newArgs = append(newArgs, args[:len(args)-1]...)

	return constructRootTerm("Do", p.Term_FUNCALL, newArgs, map[string]interface{}{})
}
970274
func (q *TypeQuery) Source() (interface{}, error) {
	source := make(map[string]interface{})
	params := make(map[string]interface{})
	source["type"] = params
	params["value"] = q.typ
	return source, nil
}
172668
func (t Term) Includes(args ...interface{}) Term {
	return constructMethodTerm(t, "Includes", p.Term_INCLUDES, args, map[string]interface{}{})
}
105785
func (t Term) Merge(args ...interface{}) Term {
	return constructMethodTerm(t, "Merge", p.Term_MERGE, funcWrapArgs(args), map[string]interface{}{})
}
815
func (order *TermsOrder) Source() (interface{}, error) {
	source := make(map[string]string)
	if order.Ascending {
		source[order.Field] = "asc"
	} else {
		source[order.Field] = "desc"
	}
	return source, nil
}
258512
func (t Term) Get(args ...interface{}) Term {
	return constructMethodTerm(t, "Get", p.Term_GET, args, map[string]interface{}{})
}
336194
func (t *Template) term() Node {
	switch token := t.nextNonSpace(); token.typ {
	case itemError:
		t.errorf("%s", token.val)
	case itemIdentifier:
		return t.newIdentifier(token.val, token.pos, t.lex.lineNumber())
	case itemNil:
		return t.newNil(token.pos)
	case itemField:
		return t.newField(token.pos, token.val)
	case itemBool:
		return t.newBool(token.pos, token.val == "true")
	case itemCharConstant, itemComplex, itemNumber:
		number, err := t.newNumber(token.pos, token.val, token.typ)
		if err != nil {
			t.error(err)
		}
		return number
	case itemLeftParen:
		pipe := t.expression("parenthesized expression")
		if token := t.next(); token.typ != itemRightParen {
			t.errorf("unclosed right paren: unexpected %s", token)
		}
		return pipe
	case itemString, itemRawString:
		s, err := unquote(token.val)
		if err != nil {
			t.error(err)
		}
		return t.newString(token.pos, token.val, s)
	}
	t.backup()
	return nil
}
326308
func (q *TermsQuery) TermsLookup(lookup *TermsLookup) *TermsQuery {
	q.termsLookup = lookup
	return q
}
576083
func (c Call) MakeExpr(output *Term) *Expr {
	terms := []*Term(c)
	return NewExpr(append(terms, output))
}
367773
func (t *TermsLookup) Source() (interface{}, error) {
	src := make(map[string]interface{})
	if t.index != "" {
		src["index"] = t.index
	}
	if t.typ != "" {
		src["type"] = t.typ
	}
	if t.id != "" {
		src["id"] = t.id
	}
	if t.path != "" {
		src["path"] = t.path
	}
	if t.routing != "" {
		src["routing"] = t.routing
	}
	return src, nil
}
869235
func (h *Client) UserLanguage(userLanguage string) *Client {
	h.userLanguage = userLanguage
	h.userLanguageSet = true
	return h
}
1301481
func (t Term) Limit(args ...interface{}) Term {
	return constructMethodTerm(t, "Limit", p.Term_LIMIT, args, map[string]interface{}{})
}
914816
func (r Resources) MergeByLanguageInterface(in interface{}) (interface{}, error) {
	r2, ok := in.(Resources)
	if !ok {
		return nil, fmt.Errorf("%T cannot be merged by language", in)
	}
	return r.MergeByLanguage(r2), nil
}
316011
func Languages() []string {
	out := make([]string, 0, len(languages))
	for name := range languages {
		out = append(out, name)
	}
	return out
}
690972
func (q *TermSuggester) Source(includeName bool) (interface{}, error) {
	// "suggest" : {
	//   "my-suggest-1" : {
	//     "text" : "the amsterdma meetpu",
	//     "term" : {
	//       "field" : "body"
	//     }
	//   },
	//   "my-suggest-2" : {
	//     "text" : "the rottredam meetpu",
	//     "term" : {
	//       "field" : "title",
	//     }
	//   }
	// }
	ts := &termSuggesterRequest{}
	if q.text != "" {
		ts.Text = q.text
	}

	suggester := make(map[string]interface{})
	ts.Term = 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([]interface{}, len(q.contextQueries))
		for i, query := range q.contextQueries {
			src, err := query.Source()
			if err != nil {
				return nil, err
			}
			ctxq[i] = src
		}
		suggester["contexts"] = ctxq
	}

	// Specific to term suggester
	if q.suggestMode != "" {
		suggester["suggest_mode"] = q.suggestMode
	}
	if q.accuracy != nil {
		suggester["accuracy"] = *q.accuracy
	}
	if q.sort != "" {
		suggester["sort"] = q.sort
	}
	if q.stringDistance != "" {
		suggester["string_distance"] = q.stringDistance
	}
	if q.maxEdits != nil {
		suggester["max_edits"] = *q.maxEdits
	}
	if q.maxInspections != nil {
		suggester["max_inspections"] = *q.maxInspections
	}
	if q.maxTermFreq != nil {
		suggester["max_term_freq"] = *q.maxTermFreq
	}
	if q.prefixLength != nil {
		suggester["prefix_length"] = *q.prefixLength
	}
	if q.minWordLength != nil {
		suggester["min_word_len"] = *q.minWordLength
	}
	if q.minDocFreq != nil {
		suggester["min_doc_freq"] = *q.minDocFreq
	}

	if !includeName {
		return ts, nil
	}

	source := make(map[string]interface{})
	source[q.name] = ts
	return source, nil
}