Erweitere die Paperless-Suche um Suchart, weitere Filter und eine Vorschau je Treffer, damit sich das richtige Dokument finden und erkennen lässt.
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 6m5s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 22s

Standard ist jetzt Titel und Inhalt ohne Index; Titel, Inhalt und Volltextindex sind wählbar. Neue Filter: Speicherpfad, Tag-Verknüpfung (alle, eines, keines), "ohne" bei Korrespondent, Typ und Pfad, Hinzugefügt-Datum und Archivnummer. Treffer zeigen Vorschaubild, Textauszug, Tags, Typ und Seitenzahl; die Vorschaubilder laufen über den Server.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-10-24 20:41:06 +02:00
1 parent 4327f5a434
commit 9089d830b3
10 files changed
+760 -185

No files matched your search

+62 -80
View File
@@ -28,6 +28,7 @@ from app.sources import (
list_connectors,
owned_connector,
paperless_content,
paperless_thumbnail,
parse_connector,
probe,
save_connector,
@@ -264,40 +265,53 @@ def _mail_bytes(data: bytes, media_type: str, filename: str, inline: bool = Fals
)
class SearchFilters:
"""The query parameters every search route shares. A source answers only those it declares."""
def __init__(
self,
mode: str = "",
title: str = "",
correspondent: str = "",
document_type: str = "",
storage_path: str = "",
tag: str = "",
tag_mode: str = "",
document_from: str = "",
document_to: str = "",
added_from: str = "",
added_to: str = "",
asn: str = "",
sort: str = "",
cursor: str = "",
):
self.values = {
"mode": mode,
"title": title,
"correspondent": correspondent,
"document_type": document_type,
"storage_path": storage_path,
"tag": tag,
"tag_mode": tag_mode,
"document_from": document_from,
"document_to": document_to,
"added_from": added_from,
"added_to": added_to,
"asn": asn,
"sort": sort,
"cursor": cursor,
}
@router.get("/api/v1/sources/paperless/documents")
def search_paperless(
q: str = "",
connector_id: UUID | None = None,
title: str = "",
correspondent: str = "",
document_type: str = "",
tag: str = "",
document_from: str = "",
document_to: str = "",
sort: str = "",
cursor: str = "",
filters: SearchFilters = Depends(),
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
return _run_search(
"paperless",
conn,
principal.account_id,
q.strip(),
connector_id,
"",
None,
{
"title": title,
"correspondent": correspondent,
"document_type": document_type,
"tag": tag,
"document_from": document_from,
"document_to": document_to,
"sort": sort,
"cursor": cursor,
},
)
return _run_search("paperless", conn, principal.account_id, q.strip(), connector_id, "", None, filters.values)
@router.get("/api/v1/sources/{kind}/facets")
@@ -328,6 +342,17 @@ def preview_paperless_document(
)
@router.get("/api/v1/sources/paperless/documents/{document_id}/thumb")
def thumbnail_paperless_document(
document_id: str,
connector_id: UUID,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
data, media = paperless_thumbnail(conn, principal.account_id, document_id, connector_id)
return Response(content=data, media_type=media, headers=_PRIVATE)
@router.get("/api/v1/sources/imap/mailboxes")
def list_mailboxes(
connector_id: UUID,
@@ -343,39 +368,15 @@ def search_mail(
q: str = "",
mailbox: str = "",
before: int | None = None,
title: str = "",
correspondent: str = "",
document_type: str = "",
tag: str = "",
document_from: str = "",
document_to: str = "",
sort: str = "",
cursor: str = "",
uidvalidity: int | None = None,
filters: SearchFilters = Depends(),
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
if before is not None and before < 1:
raise unprocessable("Die Seitenangabe ist ungültig.")
return _run_search(
"imap",
conn,
principal.account_id,
q.strip(),
connector_id,
mailbox.strip(),
before,
{
"title": title,
"correspondent": correspondent,
"document_type": document_type,
"tag": tag,
"document_from": document_from,
"document_to": document_to,
"sort": sort,
"cursor": cursor,
},
uidvalidity,
"imap", conn, principal.account_id, q.strip(), connector_id, mailbox.strip(), before, filters.values, uidvalidity
)
@@ -432,12 +433,18 @@ def _connector_parts(body: ConnectorIn, current: dict | None) -> tuple[str, dict
_SEARCH_FLAGS = {
"mode": "mode",
"title": "title",
"correspondent": "correspondent",
"document_type": "document_type",
"storage_path": "storage_path",
"tag": "tags",
"tag_mode": "tag_mode",
"document_from": "document_range",
"document_to": "document_range",
"added_from": "added_range",
"added_to": "added_range",
"asn": "asn",
"sort": "sort",
"cursor": "continuation",
}
@@ -474,38 +481,13 @@ def search_source(
connector_id: UUID | None = None,
mailbox: str = "",
before: int | None = None,
title: str = "",
correspondent: str = "",
document_type: str = "",
tag: str = "",
document_from: str = "",
document_to: str = "",
sort: str = "",
cursor: str = "",
filters: SearchFilters = Depends(),
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
if before is not None and before < 1:
raise unprocessable("Die Seitenangabe ist ungültig.")
return _run_search(
kind,
conn,
principal.account_id,
q.strip(),
connector_id,
mailbox.strip(),
before,
{
"title": title,
"correspondent": correspondent,
"document_type": document_type,
"tag": tag,
"document_from": document_from,
"document_to": document_to,
"sort": sort,
"cursor": cursor,
},
)
return _run_search(kind, conn, principal.account_id, q.strip(), connector_id, mailbox.strip(), before, filters.values)
@router.get("/api/v1/sources/{kind}/navigate")