Search
Bellamy Book provides full-text search across users, posts, blogs, and hashtags using Elasticsearch/OpenSearch. The Search API (api/Search) supports universal search, type-specific search, autocomplete, recommendations, trending, and search history. The social frontend has a search page that calls these endpoints.
Overview
- Backend: ElasticsearchSyncWorker and ElasticsearchSyncJob (Quartz) keep PostgreSQL data synced to Elasticsearch. SearchController (
api/Search) queries Elasticsearch and returns unified or type-specific results. - Frontend: Search page (e.g.
/search) — query input, filters by type (user, post, blog, hashtag), results list. Blocked users are excluded from results. - Analytics: Search queries can be recorded for analytics and recommendations (admin search analytics, recommendation service).
API Endpoints (api/Search)
All search endpoints require authorization (User, Admin, or Moderator role).
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/Search | Universal search — query: q (required), types (user, post, blog, hashtag), page, pageSize, sortBy, sortDesc. Returns results by type; blocked users excluded. |
| GET | /api/Search/autocomplete | Autocomplete suggestions — query: q, type, limit |
| GET | /api/Search/recommendations | Personalized search recommendations (e.g. based on history) |
| GET | /api/Search/trending | Trending search terms |
| POST | /api/Search/record | Record a search (body: query, types) for analytics/recommendations |
| GET | /api/Search/history | Current user's search history |
| DELETE | /api/Search/history | Clear search history |
| GET | /api/Search/related | Related content for a given query or context |
| GET | /api/Search/posts | Search posts only — query: q, page, pageSize, filters |
| GET | /api/Search/blogs | Search blogs only |
| GET | /api/Search/users | Search users only |
| GET | /api/Search/hashtags | Search hashtags only |
Indexing and sync
- Elasticsearch/OpenSearch holds indexes for users, posts, blogs, and hashtags.
- ElasticsearchSyncWorker (Kafka) syncs on content events; ElasticsearchSyncJob (Quartz, default every 15 minutes) performs catch-up sync. See Scheduled Jobs and Workers.
Related
- Blogs — Blog content is searchable
- Hashtags — Hashtag search
- Posts — Post content is searchable
- Architecture — Database — Elasticsearch in polyglot persistence
- Scheduled Jobs — ElasticsearchSyncJob