This document describes the v2 Favorites API of Fess. For the common response envelope, error model, and CSRF, see API Overview.
The base URL is http://<Server Name>/api/v2/ (local environment example: http://localhost:8080/api/v2).
Note
To use the favorites feature, the user.favorite setting must be enabled.
Fetching Favorite Documents List
Request
| HTTP Method | GET |
| Endpoint | /api/v2/favorites |
Returns the IDs of documents that the calling user has previously added to favorites, among search results identified by query_id. query_id is the opaque identifier (query_id field) returned by the search API (/search).
An anonymous caller (no user code associated with the session) results in auth_required (401). When the user.favorite feature is disabled, it returns invalid_request (400). When query_id does not match a cached result set in the session, it returns 200 with an empty data array.
Request Parameters
query_id | The opaque query_id returned by the search API (/search) (query, required, str). |
Table: Request Parameters
Response
On success (200), the following fields are returned directly under response in the common envelope.
Each field is described below.
record_count | Number of favorite documents in data (int). |
data | Array of favorite documents in the queried result set, preserving search result order. Each element is {doc_id}. |
Table: Response Fields
Error Response
For details on the error model, see API Overview. The HTTP statuses returned by this endpoint are as follows.
Table: Error Response
Fetching Favorite Status
Request
| HTTP Method | GET |
| Endpoint | /api/v2/documents/{docId}/favorite |
Retrieves the favorite status of the specified document.
Request Parameters
Table: Request Parameters
Response
On success (200), the following fields are returned directly under response in the common envelope.
Each field is described below.
doc_id | Document ID (str). |
favorite | Whether the calling user has favorited this document (bool). |
count | Total favorite count for this document (int64). |
Table: Response Fields
Error Response
For details on the error model, see API Overview. The HTTP statuses returned by this endpoint are as follows.
Table: Error Response
Adding a Favorite
Request
| HTTP Method | POST |
| Endpoint | /api/v2/documents/{docId}/favorite |
Adds the specified document to favorites. Since this is a state-changing request, the X-Fess-CSRF-Token header is required (see API Overview).
Request Parameters
Table: Request Parameters
Request Body
Send a JSON (FavoritePostRequest) with Content-Type: application/json containing the following fields.
Table: Request Body
Response
On success (200), the following fields are returned directly under response in the common envelope.
Each field is described below.
Table: Response Fields
Error Response
For details on the error model, see API Overview. The HTTP statuses returned by this endpoint are as follows.
Table: Error Response