Last active
August 29, 2015 14:05
-
-
Save tbje/8fcc68c26e40de4f2164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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