I have a list of 'entries' with a corresponding list of tags. I need to write a slick query where I am given a list of 'tags' and I must search through an MYSQL table to search for table entries who have those given 'tags' as a subset of one column of type 'fulltext'. Each post is a row of the table and contains the post number in one column and a list of tags of type FULLTEXT in another column. There can be more than one tag in this list. There can also be more than one tag in the list of tags I am searching for. Is there a way to do a FULLTEXT boolean search in Slick to find the posts with the correct tags?
4
votes
2 Answers
8
votes
This is an older question, but in case somebody else runs into this (like me) - maybe this helps. As Christopher pointed out it works straightforward with SimpleExpression.
val fulltextMatch = SimpleExpression.binary[String,String,Boolean] { (col,search,qb) =>
qb.sqlBuilder += "match("
qb.expr(col)
qb.sqlBuilder += ") against ("
qb.expr(search)
qb.sqlBuilder += " in boolean mode)"
}
and then use as:
.. if fulltextMatch(t.comment, s.bind)
0
votes
Not supported out of the box, but you should be able to implement the MATCH AGAINST syntax using a SimpleExpression. There is an example in the Slick unit tests.
Also see http://slick.typesafe.com/doc/2.0.2/userdefined.html#scala-database-functions
Please let us know of your success. Maybe you can post a gist.