Function admin_top_queries_handler

Source
pub async fn admin_top_queries_handler(
    headers: HeaderMap,
    __arg1: State<AppState>,
) -> Result<Json<TopQueriesResponse>, StatusCode>
Expand description

HTTP handler for retrieving top search queries.

Returns the most frequently searched terms for analytics and content optimization purposes. This endpoint requires admin authentication via the X-Admin-Key header.

§Headers

  • X-Admin-Key: Required admin API key for authentication

§Returns

  • 200 OK: JSON response with top search queries and their frequencies
  • 401 Unauthorized: If admin authentication fails
  • 500 Internal Server Error: If query retrieval fails

§Response

Returns up to 20 most frequently searched queries with their occurrence counts. Queries are normalized for proper aggregation (lowercased, trimmed).

§Example

GET /admin/top-queries
X-Admin-Key: your-admin-key