// NewFuzzyQuery creates a new fuzzy query.
322455
func NewFuzzyQuery(name string, value interface{}) *FuzzyQuery {
	q := &FuzzyQuery{
		name:  name,
		value: value,
	}
	return q
}
589784
func (q *QueryStringQuery) FuzzyPrefixLength(fuzzyPrefixLength int) *QueryStringQuery {
	q.fuzzyPrefixLength = &fuzzyPrefixLength
	return q
}
41249
func newAEDataQueryBuilderWithKind(kind string) *aeDataQueryBuilder {
	q := datastore.NewQuery(kind)
	bldr := &aeDataQueryBuilder{q: q}
	bldr.Foo = &aeDataQueryProperty{
		bldr: bldr,
		name: "Foo",
	}

	if plugger, ok := interface{}(bldr).(qbgutils.Plugger); ok {
		bldr.plugin = plugger.Plugin()
		bldr.plugin.Init("AEData")
	}

	return bldr
}
892636
func (q *MultiMatchQuery) ZeroTermsQuery(zeroTermsQuery string) *MultiMatchQuery {
	q.zeroTermsQuery = zeroTermsQuery
	return q
}
46867
func NewNumericRangeQuery(min, max *float64) *query.NumericRangeQuery {
	return query.NewNumericRangeQuery(min, max)
}
490575
func NewFloat(f float64, valid bool) Float {
	return Float{
		NullFloat64: sql.NullFloat64{
			Float64: f,
			Valid:   valid,
		},
	}
}
643862
func (s *DocumentSuggesterOptions) SetFuzzyMatching(v string) *DocumentSuggesterOptions {
	s.FuzzyMatching = &v
	return s
}
788824
func NewIdsQuery(types ...string) *IdsQuery {
	return &IdsQuery{
		types:  types,
		values: make([]string, 0),
	}
}
405761
func newPulloutSubquery(opcode engine.PulloutOpcode, sqName, hasValues string, subquery builder) *pulloutSubquery {
	return &pulloutSubquery{
		subquery: subquery,
		eSubquery: &engine.PulloutSubquery{
			Opcode:         opcode,
			SubqueryResult: sqName,
			HasValues:      hasValues,
		},
	}
}
1051291
func NewFromRawQuery(rawQuery string) *QueryString {
	qs := new(QueryString)
	qs.fields = make(map[string]string)

	for {
		i := strings.IndexRune(rawQuery, '=')
		if i == -1 {
			break
		}
		name := rawQuery[:i]
		rawQuery = rawQuery[i+1:]

		i = strings.IndexFunc(rawQuery, charClassDetector(1, 1))
		var value string
		if i == -1 {
			value = rawQuery
		} else {
			value = rawQuery[:i]
			rawQuery = rawQuery[i+1:]
		}

		qs.fields[name] = value

		if i == -1 {
			break
		}
	}

	return qs
}
1254963
func NewNumericRangeQuery(min, max *float64) *NumericRangeQuery {
	return NewNumericRangeInclusiveQuery(min, max, nil, nil)
}
570093
func NewObjQuery(obj caddyshack.StoreObject, db *CouchStore) (q *CouchQuery) {
	q = new(CouchQuery)
	prefix := "doc"

	viewName := q.GetViewName(obj)
	view := couchdb.NewView(viewName, prefix, q.getCondition(obj, prefix), q.getEmits(obj))
	keyName := q.getByName(obj, prefix)
	if keyName != "" {
		view.KeyName = keyName
	} else {
		view.KeyName = prefix + "._id"
	}
	//Creates the DesignDoc if it does not exist.
	desDoc := db.GetDesignDoc(db.Res.DesDoc)
	index, status := desDoc.CheckExists(viewName)

	log.Debug("Index, Status", index, status)

	if status == false {
		desDoc.AddView(view)
		log.Debug("Added view", desDoc, view)
		// FIXME: Removing object update for now. Saved by the guard.
		err := desDoc.SaveDoc()
		if err != nil {
			panic(err)
		}
	} else {
		if index < 0 {
			desDoc.LastView = view
		} else {
			desDoc.Views[index] = view
		}
	}

	q.desDoc = desDoc
	q.ViewName = viewName
	q.Store = db
	q.BufferSize = defaultBufferSize

	return
}
1271746
func newQuery(collection *Collection) *query {
	q := &query{
		collection: collection,
		pool:       collection.pool,
	}
	// For now, only indexed collections are queryable. This might change in
	// future versions.
	if !collection.index {
		q.setError(fmt.Errorf("zoom: error in NewQuery: Only indexed collections are queryable"))
		return q
	}
	return q
}
306719
func NewPrefixQuery(prefix string) *PrefixQuery {
	q := &PrefixQuery{newFtsQueryBase()}
	q.options["prefix"] = prefix
	return q
}
747115
func NewQuery() *Query {
	return &Query{
		Metadata: make(flux.Metadata),
		results:  make(chan flux.Result, 1),
	}
}
16393
func HasFuzzySearch(ctx context.Context) bool {
	_, ok := ctx.Value(ctxKeyFuzzySearch).(bool)
	return ok
}
915834
func NewWildcardQuery(name, wildcard string) WildcardQuery {
	q := WildcardQuery{
		name:     name,
		wildcard: wildcard,
		boost:    -1.0,
	}
	return q
}