# Filter & Sort Media Items

Filter and sort media items with advanced criteria.

**Endpoint**: `POST /api/media-items/filter`
**Auth**: Required
**Content-Type**: `application/json`

## Request Body

| Field | Type | Required | Description |
|--------|------|-----------|-------------|
| library_id | string | Yes | Library UUID |
| author_filter | string | No | Filter by author name |
| series_filter | string | No | Filter by series name |
| genre_filter | string | No | Filter by genre |
| year_min | integer | No | Minimum copyright year |
| year_max | integer | No | Maximum copyright year |
| has_cover | boolean | No | Filter by cover image existence |
| sort | string | No | Sort field and order (e.g., "title ASC", "created_at DESC") |
| limit | integer | No | Number of results (default 20) |
| offset | integer | No | Number to skip |

### Example Request

```json
{
  "library_id": "uuid",
  "author_filter": "Rowling",
  "series_filter": "Harry Potter",
  "genre_filter": "Fantasy",
  "year_min": 1997,
  "year_max": 2007,
  "has_cover": true,
  "sort": "title ASC",
  "limit": 20,
  "offset": 0
}
```

## Response (200 OK)

```json
{
  "media_items": [
    {
      "id": "uuid",
      "title": "Book Title",
      "author": "Author Name",
      "match_score": 0.95
    }
  ],
  "total": 7
}
```

## Error Responses

| Code | Description |
|------|-------------|
| 400 | Invalid filter parameters |
| 401 | Invalid or expired token |
| 403 | User does not have access to this library |
