// NewMoreLikeThisQuery creates a new more-like-this query.
503763
func NewMoreLikeThisQuery(likeText string) MoreLikeThisQuery {
	return MoreLikeThisQuery{
		likeText:  likeText,
		fields:    make([]string, 0),
		ids:       make([]string, 0),
		docs:      make([]*MoreLikeThisQueryItem, 0),
		stopWords: make([]string, 0),
	}
}
577907
func (item *MoreLikeThisQueryItem) Source() (interface{}, error) {
	if item.likeText != "" {
		return item.likeText, nil
	}

	source := make(map[string]interface{})

	if item.index != "" {
		source["_index"] = item.index
	}
	if item.typ != "" {
		source["_type"] = item.typ
	}
	if item.id != "" {
		source["_id"] = item.id
	}
	if item.doc != nil {
		source["doc"] = item.doc
	}
	if len(item.fields) > 0 {
		source["fields"] = item.fields
	}
	if item.routing != "" {
		source["_routing"] = item.routing
	}
	if item.fsc != nil {
		src, err := item.fsc.Source()
		if err != nil {
			return nil, err
		}
		source["_source"] = src
	}
	if item.version >= 0 {
		source["_version"] = item.version
	}
	if item.versionType != "" {
		source["_version_type"] = item.versionType
	}

	return source, nil
}
9083
func NewHasParentQuery(parentType string, query Query) *HasParentQuery {
	return &HasParentQuery{
		query:      query,
		parentType: parentType,
	}
}
1307793
func (q *MoreLikeThisQuery) IgnoreLikeText(ignoreLikeText ...string) *MoreLikeThisQuery {
	for _, s := range ignoreLikeText {
		item := NewMoreLikeThisQueryItem().LikeText(s)
		q.unlikeDocs = append(q.unlikeDocs, item)
	}
	return q
}
638636
func NewRequest(query string) (*Request, error) {
	req := &Request{Query: query}
	if err := req.Prepare(); err != nil {
		return nil, err
	}
	return req, nil
}
271429
func (q *MoreLikeThisQuery) Ids(ids ...string) *MoreLikeThisQuery {
	for _, id := range ids {
		item := NewMoreLikeThisQueryItem().Id(id)
		q.docs = append(q.docs, item)
	}
	return q
}
441879
func NewConjunctionQuery(queries ...FtsQuery) *ConjunctionQuery {
	q := &ConjunctionQuery{newFtsQueryBase()}
	q.options["conjuncts"] = []FtsQuery{}
	return q.And(queries...)
}
1003781
func (c *Cursor) fetchMore() error {
	var err error

	if !c.fetching {
		c.fetching = true

		if c.closed {
			return errCursorClosed
		}

		q := Query{
			Type:  p.Query_CONTINUE,
			Token: c.token,
		}

		c.mu.Unlock()
		_, _, err = c.conn.Query(c.ctx, q)
		c.mu.Lock()
	}

	return err
}
792595
func newQuery(t Term, qopts map[string]interface{}, copts *ConnectOpts) (q Query, err error) {
	queryOpts := map[string]interface{}{}
	for k, v := range qopts {
		queryOpts[k], err = Expr(v).Build()
		if err != nil {
			return
		}
	}
	if copts.Database != "" {
		queryOpts["db"], err = DB(copts.Database).Build()
		if err != nil {
			return
		}
	}

	builtTerm, err := t.Build()
	if err != nil {
		return q, err
	}

	// Construct query
	return Query{
		Type:      p.Query_START,
		Term:      &t,
		Opts:      queryOpts,
		builtTerm: builtTerm,
	}, nil
}
994851
func NewPhraseQuery(terms ...string) *PhraseQuery {
	q := &PhraseQuery{newFtsQueryBase()}
	q.options["terms"] = terms
	return q
}
616512
func (q MoreLikeThisQuery) Fields(fields ...string) MoreLikeThisQuery {
	q.fields = append(q.fields, fields...)
	return q
}
153759
func NewPrefixQuery(name string, prefix string) *PrefixQuery {
	return &PrefixQuery{name: name, prefix: prefix}
}
1100505
func (dht *IpfsDHT) newQuery(k string, f queryFunc) *dhtQuery {
	return &dhtQuery{
		key:         k,
		dht:         dht,
		qfunc:       f,
		concurrency: maxQueryConcurrency,
	}
}
645578
func (q *MoreLikeThisQuery) BoostTerms(boostTerms float64) *MoreLikeThisQuery {
	q.boostTerms = &boostTerms
	return q
}
197375
func NewQuery(query ast.Body) *Query {
	return &Query{
		query:        query,
		genvarprefix: ast.WildcardPrefix,
	}
}
64397
func NewQueryStringQuery(queryString string) *QueryStringQuery {
	return &QueryStringQuery{
		queryString: queryString,
		fields:      make([]string, 0),
		fieldBoosts: make(map[string]*float64),
	}
}
877452
func (q MoreLikeThisQuery) MinWordLen(minWordLen int) MoreLikeThisQuery {
	q.minWordLen = &minWordLen
	return q
}