Skip to content

Add a method to search across multiple columns #289

Open
@dshukertjr

Description

@dshukertjr

Feature request

Is your feature request related to a problem? Please describe.

Currently, textSearch allows to search for a search query on only one column, but in a typical application, we would want to search across multiple columns.

Currently, searching through multiple columns is possible using the rest api like this PostgREST/postgrest#2374 (comment)

GET /blog_posts?or=(title.fts.searchTerm,content.fts.searchTerm)

That means we can perform full text search across multiple columns via js client can be done like this:

const { data, error } = await supabase
  .from('blog_posts')
  .select('*')
  .or('title.fts.searchTerm,content.fts.searchTerm')

However, developers would need to use the rest api syntax to perform text search, so it might not be a nice developer experience.

Describe the solution you'd like

This is a suggestion from @steve-chavez, so I don't want to take any credits, but we could introduce a new method where we combine multiple text search just like match like this:

const { data, error } = await supabase
  .from('blog_posts')
  .select('*')
  .textMatch({title: 'sometitle', contents: 'somecontent'})

Describe alternatives you've considered

We can use or filter to combine multiple text search query.

const { data, error } = await supabase
  .from('blog_posts')
  .select('*')
  .or('title.fts.searchTerm,content.fts.searchTerm')

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions