Skip to content

Full-text search support #58

Open
Open
@techniq

Description

@techniq

I'm proposing to add the search query operator to support full-text search

Comment.filter({
  where: {
    content: {
      'search': 'some search terms'
    }
  }
});

you could also specify multiple columns using a comma separated field (similar to how near queries do for lat/long columns)

Comment.filter({
  where: {
    'title,content': {
      'search': 'some search terms'
    }
  }
});

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')

alter table `comment` add fulltext(`content`);
select * from comment where match(`content`) against ('some word')

-- or multiple columns
alter table `comment` add fulltext(`title`, `content`);
select * from comment where match(`title`, `content`) against ('some word')

Need to determine is we should always use boolean full-text searches

Postgres

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions