Full text search


We’re trying to performe full text search similar to laravel:
DB::raw("MATCH (document) AGAINST ('".$term."') AS score")

This raw query works well in sql if you set index fulltext on a wished column in table:
SELECT * FROM counties WHERE MATCH (keywords) AGAINST ('searchedKeyword')

We tried something like this but keep getting “Expected 1 bindings, saw 0” error:
await Model.query().whereRaw("MATCH (keywords)", "AGAINST ('searchedKeyword')")


Aren’t 2 queries different? One DB::raw is different from whereRaw. Also you are passing 2 arguments to whereRaw, you just need to pass a string literal to it.

await Model.query().whereRaw("MATCH (keywords) AGAINST ('searchedKeyword')")


yes, thanks
also i can’t figure how to add full text index in migration table in adonis!?
possibly on more than one column

Thanks again on a quick reply


found it… in case someone else is wondering, here is the solution:

up() {
this.raw('ALTER TABLE table_name ADD FULLTEXT (`coulmn_name`)')