Skip to content

feat(search): add matchField and PostgreSQL tsvector full-text index (#71) - #78

Open
sun-970 wants to merge 5 commits into
bytefolk:mainfrom
sun-970:feat/search-matchfield-tsvector
Open

sun-970 wants to merge 5 commits into
bytefolk:mainfrom
sun-970:feat/search-matchfield-tsvector

Conversation

@sun-970

@sun-970 sun-970 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Closes #71

Summary

  • Add contentSearch column to persist plain-text extraction of TipTap content
  • Add search_vector tsvector column with GIN index, maintained by trigger
  • Use websearch_to_tsquery() for indexed retrieval when available
  • Report matchField (title | content | both) in search results
  • Keep contains fallback for SQLite/unmigrated environments
  • Update collaboration service to populate contentSearch on save

Test plan

  • Unit tests for plain-text extractor (10 tests)
  • Unit tests for search functionality (11 tests)
  • All 333 main app tests pass
  • Collaboration service builds successfully

user added 5 commits September 17, 2026 21:03
…sort filters (bytefolk#68)

- Internal GET /api/doc and API v1 GET /api/v1/documents now search both
  title and content (OR) instead of title-only
- Add after/before query params for updatedAt range filtering
- Add sort query param (updated_desc|updated_asc|created_desc|created_asc)
- No schema migration needed — uses Prisma OR + contains
…or pagination

- Extract shared doc-query.ts module for query parsing and where/orderBy builders
- Fix getOrderBy to return mutable array (TS2322 build failure)
- Add mode: insensitive to /api/doc title search for consistency with v1
- Return 400 for invalid date/sort params instead of silently ignoring
- Disable cursor pagination for created_* sort orders (cursor is updatedAt-based)
- Unify search/date/sort logic between /api/doc and /api/v1/documents
…ytefolk#71)

- Add `contentSearch` column to persist plain-text extraction of TipTap content
- Add `search_vector` tsvector column with GIN index, maintained by trigger
- Use `websearch_to_tsquery()` for indexed retrieval when available
- Report `matchField` (title | content | both) in search results
- Keep `contains` fallback for SQLite/unmigrated environments
- Update collaboration service to populate `contentSearch` on save

@waterbro-8 waterbro-8 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indexed matchField + search_vector is the right follow-on for #71.

Please rebase onto current main after #69 (content search + time/sort). This PR overlaps src/lib/doc-query.ts, src/lib/api-v1-documents.ts, src/app/api/doc/route.ts, and the v1 list tests. Landing both without a rebase will conflict; keep this PR additive (contentSearch column, tsvector/GIN, matchField, collaboration extractor).

fullTextSearch parameterizes websearch_to_tsquery via $queryRawUnsafe placeholders — that part looks fine. I cannot push sun-970/doc.

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.

feat(search): add matchField and PostgreSQL tsvector full-text index

2 participants