You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently knex has an open issue since 2014 to (generically) support full-text searches. In the interim, we can do as other have and use whereRaw and syntax based on the database type.
MySQL
I currently have been using MySQL (Google Cloud SQL) and plan to implement this first as it's pretty straight forward. Add a fulltext to the column(s) designed and then use match(column_name) against ('seach terms')
altertable`comment` add fulltext(`content`);
select*from comment where match(`content`) against ('some word')
-- or multiple columnsaltertable`comment` add fulltext(`title`, `content`);
select*from comment where match(`title`, `content`) against ('some word')
While I haven't looked into it much yet, Postgres appears a little more complicated and need to better understand tsvector. The following articles look like a good start.
Until it's decided how best to handle this, as of version 0.11.10, you can register a custom query operator and provide your own implementation (or override an existing one). For example, here's what I (roughly) use for MySQL
varadapter=newDSSqlAdapter({
...
queryOperators: {'search': (query,field,value)=>{returnquery.whereRaw(`MATCH(${field}) AGAINST(? IN BOOLEAN MODE)`,value)},'|search': (query,field,value)=>{returnquery.orWhereRaw(`MATCH(${field}) AGAINST(? IN BOOLEAN MODE)`,value)}}}
Activity
techniq commentedon Mar 15, 2016
Until it's decided how best to handle this, as of version 0.11.10, you can register a custom query operator and provide your own implementation (or override an existing one). For example, here's what I (roughly) use for MySQL