Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseβ€’4y agoβ€’
1 reply
LukasV

Integrating Full Text Search with supabase

Hi, I have few questions regarding implementation of Supabase full text search, I was reading the docs here https://supabase.com/docs/guides/database/full-text-search#to_tsvector

Currently I have custom react hook function:

const getFullTextSearchIngredients = async (
  queryString: string | undefined
) => {
  let query = supabase
    .from<SupabaseIngredient>('ingredients')
    .select(
      '*',
      {
        count: 'exact'
      }
    )
    .order('popularity', { ascending: false })
    .limit(20);

  if (queryString) {
    query = query.textSearch('product_name', queryString, {
      type: 'phrase'
    });
  }

  const { data, count, error } = await query;

  if (error) {
    throw new Error(`${error.message}: ${error.details}`);
  }

  if (count === 0) {
    return null;
  }
  return data;
};
const getFullTextSearchIngredients = async (
  queryString: string | undefined
) => {
  let query = supabase
    .from<SupabaseIngredient>('ingredients')
    .select(
      '*',
      {
        count: 'exact'
      }
    )
    .order('popularity', { ascending: false })
    .limit(20);

  if (queryString) {
    query = query.textSearch('product_name', queryString, {
      type: 'phrase'
    });
  }

  const { data, count, error } = await query;

  if (error) {
    throw new Error(`${error.message}: ${error.details}`);
  }

  if (count === 0) {
    return null;
  }
  return data;
};

I pictured an example query, if you have a look "Chicken, broiler or fryes, breast, skinless..." should've been retrieved in both queries, but is only present in the first one.

Now, I do realise that the ingredient name is very obscure and could be renamed, however as I was reading docs there were different functions mentioned such as:
to_tsvector()
to_tsvector()
to_tsquery()
to_tsquery()
@@
@@
.

I don't understand what they do, but can they be included in supabase javascript method
.textSearch()
.textSearch()
to improve the search?

Or is it just postgres limitations and I should simply rename the ingredients 😁
unknown.png
Full Text Search | Supabase
How to use full text search in PostgreSQL.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Full Text Search
SupabaseSSupabase / help-and-questions
4y ago
Full Text Search
SupabaseSSupabase / help-and-questions
4y ago
Full Text Search
SupabaseSSupabase / help-and-questions
3y ago
Fuzzy Full Text Search
SupabaseSSupabase / help-and-questions
4y ago