Skip to content

Instantly share code, notes, and snippets.

@tbje
Last active Aug 29, 2015
Embed
What would you like to do?
case class Match(cols: Column[_]*) {
def against(what: Column[_], modifier: SearchModifier.Value*) =
SimpleExpression[Boolean]{ case (nodes, qb) =>
import qb._
qb.sqlBuilder += "MATCH("
qb.sqlBuilder.sep(nodes, ", ")(expr(_))
qb.sqlBuilder += ") AGAINST("
qb.expr(what.toNode)
qb.sqlBuilder += " "
qb.sqlBuilder.sep(modifier, " ")(_.toString)
qb.sqlBuilder += ")"
}.apply(cols)
}
object SearchModifier extends Enumeration("IN BOOLEAN MODE", "IN NATURAL LANGUAGE MODE",
"IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION", "WITH QUERY EXPANSION") {
type SearchModifier = Value
val InBooleanMode, InNaturalLanguageMode, InNaturalLanguageModeWithQueryExpansion, WithQueryExpansion = Value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment