Skip to main content
Version: v1

.textSearch()

Finds all rows whose text or tsvector value on the stated column matches the tsquery in query.

Parameters

  • columnrequiredobject

    The column to filter on.

  • queryrequiredstring

    The Postgres tsquery string to filter with.

  • __namedParametersrequiredobject

    No description provided.

      Properties
    • configoptionalstring

      No description provided.

    • typeoptionalliteral | plain | phrase | websearch

      No description provided.

        Properties
      • websearchrequiredliteral

        No description provided.

      • phraserequiredliteral

        No description provided.

      • plainrequiredliteral

        No description provided.

      • nullrequiredliteral

        No description provided.

Examples

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

Basic normalization

Uses PostgreSQL's plainto_tsquery function.

const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
type: 'plain',
config: 'english'
})

Full normalization

Uses PostgreSQL's phraseto_tsquery function.

const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
type: 'phrase',
config: 'english'
})

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.
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat or cat'`, {
type: 'websearch',
config: 'english'
})