info:
  name: Combined Search and Filters
  type: http
  seq: 1

http:
  method: GET
  url: "{{base_url}}/api/media-items/search?library_id={{library_id}}&q=1984&author_filter=orwell&tags_filter=fic&year_min=1850&year_max=2026&sort=title ASC&has_cover=true"
  params:
    - name: library_id
      value: "{{library_id}}"
      type: query
    - name: q
      value: "1984"
      type: query
    - name: author_filter
      value: orwell
      type: query
    - name: tags_filter
      value: fic
      type: query
    - name: year_min
      value: "1850"
      type: query
    - name: year_max
      value: "2026"
      type: query
    - name: sort
      value: title ASC
      type: query
    - name: has_cover
      value: "true"
      type: query
  auth: inherit

settings:
  encodeUrl: true
  timeout: 0
  followRedirects: true
  maxRedirects: 5

docs: |-
  ## Combined Search and Filters

  Combines a search query with multiple filters to find specific media items.

  **Method:** GET

  **Endpoint:** /api/media-items/search

  **Authentication:** Required (Bearer token)

  **Query Parameters:**
  - `library_id` (string, required): Library UUID to search within
  - `q` (string, required): Search query for title/author/series/tags (fuzzy match)
  - `author_filter` (string, optional): Fuzzy match author field
  - `tags_filter` (string, optional): Fuzzy match tags field
  - `year_min` (integer, optional): Minimum copyright year (exact match)
  - `year_max` (integer, optional): Maximum copyright year (exact match)
  - `sort` (string, optional): Sort order (e.g., "title ASC", "author DESC", "created_at DESC")

  **How Combined Search Works:**
  - All filters are AND'd together (must match ALL conditions)
  - Search query (`q`) uses fuzzy matching across title, author, series, tags
  - Text filters (author, tags) use fuzzy matching
  - Year filters use exact range matching
  - Results sorted by relevance first, then by sort parameter

  **Response:** HTTP 200 (OK)
  ```json
  [
    {
      "id": "uuid",
      "title": "Foundation",
      "author": "Asimov, Isaac",
      "tags": "Sci-Fi",
      "copyright_year": 1951,
      "library_id": "uuid",
      "library_name": "E-Books"
    }
  ]
  ```

  **Example Use Cases:**
  - Find "Foundation" by "Asimov" in "Sci-Fi" tags from 1950-2000
  - Search "potter" with tags "fantasy" published after 2000
  - Find "mars" books by "sci-fi" authors sorted by date

  **Success Criteria:**
  - Status: 200
  - Returns items matching all filters
  - Results sorted by relevance then by sort parameter
  - Only returns items matching ALL specified conditions
