Commit Graph
4 Commits
Author SHA1 Message Date
Jeremias Menichelli f920456c3f feat: Improve kb search to be on pair with docs search v2 (#53454)
## Problem
though they use the same package and were conceived to be 1-1, search v2
in Docs and Kb search have some differences:
- Docs new search function is more complex to prevent no results,
improvements kb search hasn't seen. For example, when you look for
"passwor", incomplete term, Docs return results around the password
term, but kb doesn't **(see screenshot below)**.
- On kb side, we have a `content=true` parameter to fetch markdown
content from results to serve some agentic tools, but Docs search never
received that upgrade. Fair to say, in docs we are not covering all
routes in markdown at the moment so it's not 100% reliable, but whenever
we reach that, we can switch to use this search endpoint for MCP
tooling.
 
<img width="1512" height="867" alt="Screenshot 2026-11-16 at 13 06 08"
src="https://github.com/user-attachments/assets/99baa772-d4b1-4d73-bfa7-7110d5635f0a"
/>

## Solution

- Add a migration file on kb search table to match docs search SQL
function.
- Add `content=true` parameter to docs search

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

- To test kb new search function, you would have checkout this branch,
to spin locally kb search migration and search, other way we need to
wait for merging and testing. It's important Supabase integration
returns _green_ here to make sure migrations run safely.
- For docs search new parameter. Open the preview for docs in this
branch:
1. Open the search modal, and open your browser's dev tools, go to the
network tab
   1. Do a search, grab the URL and open it in a new tab
   1. Add `content=true` and `limit=3` as query prameters
1. You should get back three results with a content property containing
the markdown content of each route (see example below)
   
<img width="1273" height="793" alt="Screenshot 2026-11-16 at 13 12 32"
src="https://github.com/user-attachments/assets/d1af4663-e17e-438e-99ac-4e63f51460a9"
/>


## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-17 16:55:36 +01:00
Jeremias Menichelli e79496d5cf refactor: Point the search_v2 fn to global supabase project (#52382)
## Problem

Currently we experience a lot of empty results responses from our new
search_v2 experiment.

We are improving our search logic on our frontend plus our search
functions in the backend ot fix this.

## Solution

Improve our search setup to follow this path:
1. Same as before, strict full text search.
1. If that returns zero results, we do prefixes via wild cards, ie:
"edge fun" becomes "edge fun|*" so people don't have to type the full
term.
1. If that returns zero results, then we run the terms under OR, which
will give partial results for individual terms.
1. If that returns zero results then we are most probably under a
typo/misspelling scenario, then we use `pg_trgm` extension with a `0.4`
tier to return the closest bit, which is good cause it covers missing
first letters like "dge functions" too.

We will do this migration in three steps to not disrupt current users
under the experiments, I will be posting the PRs here:

1. First, we will create a new search_v2 table on `supabase.com [LIVE]`
project where production parts of our monorepo go + already implement
the improvements I just mentioned.
1. Re-route the ingest script to populate once per day the database
table in this new project. At this point we will have the data and the
search function ready.
1. Update the API search_v2 function to query from this new project, so
users will experience no down time. 👈 **this PR is here**

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

1. Open the preview of docs
1. Make sure you are on the search_v2 experiment or open it on an
incognito window
1. Open the search modal and run a query like "edge fun"
1. Search should return results, confirming it's using the new database
table

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-10-27 16:16:48 +01:00
Jeremias Menichelli 42dc4dbe90 chore: Add observability to search_v2 route (#51149)
## Problem

Our new Search V2 edge function can fail, we want to know when that
happens.

## Solution

Added the common Sentry wrapping plus try/catch strategy to the edge
function so we can add alerts to our Sentry dashboards and report
channels.

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

There's no way to reproduce this for the moment.


## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which references
[WORD_LIST](https://github.com/supabase/supabase/blob/master/apps/docs/WORD_LIST.md)
and the docs
[CONTRIBUTING](https://github.com/supabase/supabase/blob/master/apps/docs/CONTRIBUTING.md)
guide


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Search requests that encounter unexpected server-side errors now
receive a handled 500 response instead of an unhandled failure. Errors
returned by the search service also produce a 500 response, making
failure behavior more consistent for clients. The search query and
result-limit behavior remain unchanged.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-10-05 13:22:12 -03:00
Jeremias Menichelli 99103b3571 feat: Add edge function and hooks for search V2 (#51103) 2026-09-30 18:12:07 -03:00