// Like creates a LIKE expression.
558485
func (b ValExprBuilder) Like(val interface{}) BoolExprBuilder {
	return b.makeComparisonExpr(astLike, makeValExpr(val))
}
854670
func (q MoreLikeThisQuery) LikeText(likeText string) MoreLikeThisQuery {
	q.likeText = likeText
	return q
}
584789
func NotLike(col I, pattern string) Condition {
	return Condition{
		Type:  ConditionNotLike,
		Left:  NewOperand(col),
		Right: NewOperand(pattern),
	}
}
1139576
func NotLike(column, value string, escape ...string) Builder {
	return BuildFunc(func(d Dialect, buf Buffer) error {
		return buildLike(d, buf, column, value, true, escape)
	})
}
792368
func (b ValExprBuilder) NotLike(val interface{}) BoolExprBuilder {
	return b.makeComparisonExpr(astNotLike, makeValExpr(val))
}
1008294
func (m *matcher) match(line string) *Template {
	tmpl := m.root.search(line)
	if tmpl != nil {
		return tmpl
	}
	return m.defaultTemplate
}
368044
func NewStringLikeFunc(key Key, values ...string) (Function, error) {
	sset := set.CreateStringSet(values...)
	if err := validateStringLikeValues(stringLike, key, sset); err != nil {
		return nil, err
	}

	return &stringLikeFunc{key, sset}, nil
}
876784
func (o Operand) Match(t Operand) bool {
	if o == OperandAny || t == OperandAny {
		return true
	}
	if o == t {
		return true
	}
	return false
}
995377
func (like Like) WriteTo(w Writer) error {
	if _, err := fmt.Fprintf(w, "%s LIKE ?", like[0]); err != nil {
		return err
	}
	// FIXME: if use other regular express, this will be failed. but for compatible, keep this
	if like[1][0] == '%' || like[1][len(like[1])-1] == '%' {
		w.Append(like[1])
	} else {
		w.Append("%" + like[1] + "%")
	}
	return nil
}
1069911
func (q MoreLikeThisFieldQuery) Source() interface{} {
	// {
	//     "more_like_this_field" : {
	//         "name.first" : {
	//             "like_text" : "text like this one",
	//             "min_term_freq" : 1,
	//             "max_query_terms" : 12
	//         }
	//     }
	// }

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

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

	mlt := make(map[string]interface{})
	params[q.name] = mlt

	mlt["like_text"] = q.likeText

	if q.percentTermsToMatch != nil {
		mlt["percent_terms_to_match"] = *q.percentTermsToMatch
	}

	if q.minTermFreq != nil {
		mlt["min_term_freq"] = *q.minTermFreq
	}

	if q.maxQueryTerms != nil {
		mlt["max_query_terms"] = *q.maxQueryTerms
	}

	if len(q.stopWords) > 0 {
		mlt["stop_words"] = q.stopWords
	}

	if q.minDocFreq != nil {
		mlt["min_doc_freq"] = *q.minDocFreq
	}

	if q.maxDocFreq != nil {
		mlt["max_doc_freq"] = *q.maxDocFreq
	}

	if q.minWordLen != nil {
		mlt["min_word_len"] = *q.minWordLen
	}

	if q.maxWordLen != nil {
		mlt["max_word_len"] = *q.maxWordLen
	}

	if q.boostTerms != nil {
		mlt["boost_terms"] = *q.boostTerms
	}

	if q.boost != nil {
		mlt["boost"] = *q.boost
	}

	if q.analyzer != "" {
		mlt["analyzer"] = q.analyzer
	}

	if q.failOnUnsupportedField != nil {
		mlt["fail_on_unsupported_field"] = *q.failOnUnsupportedField
	}
	return source
}
513914
func (q *MoreLikeThisQuery) LikeText(likeTexts ...string) *MoreLikeThisQuery {
	for _, s := range likeTexts {
		item := NewMoreLikeThisQueryItem().LikeText(s)
		q.docs = append(q.docs, item)
	}
	return q
}
295764
func Expression(data string) *regexp.Regexp {
	if exp, ok := regexpMapping[data]; ok {
		return regexp.MustCompile(exp)
	}

	return nil
}
55177
func (c *Condition) AndEqual(column string, value interface{}) *Condition {
	expr := column + " = ?"
	c.And(expr, value)
	return c
}
147609
func (c Command) Expression() *regexp.Regexp {
	expr := c.Text()

	for _, param := range c.Parameters() {
		expr = strings.Replace(expr, "<"+param.Name()+":"+param.Data()+">", "("+param.Expression().String()+")", -1)
		expr = strings.Replace(expr, "<"+param.Name()+">", "("+param.Expression().String()+")", -1)
	}

	return regexp.MustCompile("^" + expr + "$")
}
248321
func (q *MoreLikeThisQuery) LikeItems(docs ...*MoreLikeThisQueryItem) *MoreLikeThisQuery {
	q.docs = append(q.docs, docs...)
	return q
}
886128
func (like Like) Or(conds ...Cond) Cond {
	return Or(like, Or(conds...))
}
1307793
func (q *MoreLikeThisQuery) IgnoreLikeText(ignoreLikeText ...string) *MoreLikeThisQuery {
	for _, s := range ignoreLikeText {
		item := NewMoreLikeThisQueryItem().LikeText(s)
		q.unlikeDocs = append(q.unlikeDocs, item)
	}
	return q
}