Skip to main content

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 in src/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

Always filter search results by daoSlug to ensure multi-tenant data 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

Always index asynchronously to avoid blocking user responses:
For bulk operations, batch index updates to reduce API calls.
Debounce search input (300-500ms) to reduce unnecessary queries.
Use pagination and reasonable result limits (10-20 per page) for performance.

Error Handling

Best Practices

Always index content immediately when created for real-time search.
Remove content from index when soft deleted to exclude from search results.
Re-index content when restored to make it searchable again.
Exclude NSFW content from indexing to maintain search quality.
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