Backend

Search

One query over the user's own files, conversations and notifications, shaped for a command palette.

pleate_backend.search looks for a few characters in the titles of the signed in user's own files, conversations and notifications, and answers rows ready for a command palette.

Endpoint

MethodPathPurpose
GET/search?q=&types=&limit=Signed in, session or API key. [{type, id, title, subtitle, url}].
ParameterMeaning
q2 to 100 characters, case insensitive, anywhere in the title. Taken literally, never as a pattern.
typesComma separated subset of files,conversations,notifications. Default: every installed one.
limit1 to 10 results per type. Default 5.
GET /api/search?q=menu
[
  { "type": "files", "id": "6720c9a1b2c3d4e5f6a7b8c9", "title": "spring-menu.pdf", "subtitle": "application/pdf", "url": "/files/6720c9a1b2c3d4e5f6a7b8c9" },
  { "type": "conversations", "id": "6720c9a1b2c3d4e5f6a7b8d0", "title": "Menu ideas", "subtitle": null, "url": "/chat/6720c9a1b2c3d4e5f6a7b8d0" }
]

Results are grouped by type, newest first. url comes from FRONTEND_PATHS["FILE"] and ["CONVERSATION"]; a notification keeps its own link when it is a path or an http(s) URL, else it points to FRONTEND_PATHS["NOTIFICATIONS"].

From React

tsx
import { useSearch } from "pleate-client/react";

const [query, setQuery] = useState("");
const { results } = useSearch(useDeferredValue(query), { types: ["files", "conversations"] });

Error codes

CodeStatusWhen
validation_error400Field codes on q (min_length, max_length), types (invalid_type) and limit.