Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved chat search #4137

Merged
merged 9 commits into from
Feb 27, 2025
Merged

Improved chat search #4137

merged 9 commits into from
Feb 27, 2025

Conversation

pablonyx
Copy link
Contributor

@pablonyx pablonyx commented Feb 26, 2025

Description

PR Description: Chat Search Optimization

  • Replaced the slow LIKE-based search with PostgreSQL full-text search using tsvector columns and GIN indexes

  • N.B. COMMIT statements in the migration are necessary because PostgreSQL requires CREATE INDEX CONCURRENTLY to run outside a transaction. Without them, the migration would fail with "CREATE INDEX CONCURRENTLY cannot run inside a transaction block"

How Has This Been Tested?

[Describe the tests you ran to verify your changes]

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 0:48am


return list(chat_sessions), has_more
return sessions, has_more
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see what list[] was removed for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was causing some typing issues!



def upgrade() -> None:
# Create a GIN index for full-text search on chat_message.message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments about why we needed this index and the improvement (per netflix context)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

@pablonyx pablonyx added this pull request to the merge queue Feb 27, 2025
Merged via the queue into main with commit abb74f2 Feb 27, 2025
22 checks passed
ahmadassaf pushed a commit to BeameryEdge/onyx that referenced this pull request Mar 2, 2025
* functional + fast

* k

* adapt

* k

* nit

* k

* k

* fix typing

* k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants