Overview
The forum system includes full-text search capabilities with real-time indexing. Topics and posts are automatically indexed when created and removed from the index when deleted.Search Service
Configuration
The search service is defined insrc/lib/search.ts:
src/lib/search.ts
Indexing Content
Index Topic
src/lib/actions/forum/search.ts
Index Post
src/lib/actions/forum/search.ts
Automatic Indexing
Content is automatically indexed when created:src/lib/actions/forum/topics.ts
Removing from Index
Remove Topic
src/lib/actions/forum/search.ts
Remove Post
src/lib/actions/forum/search.ts
Automatic Removal
Content is removed from index when soft deleted:src/lib/actions/forum/topics.ts
Search Queries
Implement search using your search service:src/lib/search.ts
UI Integration
Search Component
src/components/Forum/InstantSearch.tsx
Search Filters
Filter by Content Type
Filter by Category
Filter by Author
Multi-Tenant Isolation
NSFW Content Filtering
NSFW content is excluded from indexing:src/lib/actions/forum/topics.ts
Re-indexing Content
When restoring soft-deleted content, re-index it:src/lib/actions/forum/topics.ts
Performance Optimization
Async indexing
Async indexing
Always index asynchronously to avoid blocking user responses:
Batch operations
Batch operations
For bulk operations, batch index updates to reduce API calls.
Debounce search
Debounce search
Debounce search input (300-500ms) to reduce unnecessary queries.
Limit results
Limit results
Use pagination and reasonable result limits (10-20 per page) for performance.
Error Handling
Best Practices
Index on creation
Index on creation
Always index content immediately when created for real-time search.
Remove on deletion
Remove on deletion
Remove content from index when soft deleted to exclude from search results.
Re-index on restore
Re-index on restore
Re-index content when restored to make it searchable again.
Filter NSFW
Filter NSFW
Exclude NSFW content from indexing to maintain search quality.
Use unique IDs
Use unique IDs
Include daoSlug in document IDs for multi-tenant uniqueness.
Next Steps
Topics & Posts
Learn how content is created and managed
Moderation
Understand how moderation affects search