textSearch()

Only relevant for text and tsvector columns. Match only rows where column matches the query string in query.

Parameters#

  • columnrequired
    ColumnName

    The text or tsvector column to filter on

  • queryrequired
    string

    The query text to match with

  • optionsoptional
    object

    Named parameters

      Properties
    • configoptional
      string

      The text search configuration to use

    • typeoptional
      plain
      |
      phrase
      |
      websearch

      Change how the query text is interpreted

Notes#

For more information, see Postgres full text search.

Examples#

1const { data, error } = await supabase
2  .from('quotes')
3  .select('catchphrase')
4  .textSearch('catchphrase', `'fat' & 'cat'`, {
5    config: 'english'
6  })

Basic normalization#

Uses PostgreSQL's plainto_tsquery function.

1const { data, error } = await supabase
2  .from('quotes')
3  .select('catchphrase')
4  .textSearch('catchphrase', `'fat' & 'cat'`, {
5    type: 'plain',
6    config: 'english'
7  })

Full normalization#

Uses PostgreSQL's phraseto_tsquery function.

1const { data, error } = await supabase
2  .from('quotes')
3  .select('catchphrase')
4  .textSearch('catchphrase', `'fat' & 'cat'`, {
5    type: 'phrase',
6    config: 'english'
7  })

Websearch#

Uses PostgreSQL's websearch_to_tsquery function. This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used with advanced operators.

  • unquoted text: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
  • "quoted text": text inside quote marks will be converted to terms separated by <-> operators, as if processed by phraseto_tsquery.
  • OR: the word “or” will be converted to the | operator.
  • -: a dash will be converted to the ! operator.
1const { data, error } = await supabase
2  .from('quotes')
3  .select('catchphrase')
4  .textSearch('catchphrase', `'fat or cat'`, {
5    type: 'websearch',
6    config: 'english'
7  })