fix(filters): make path:folder query recursive

filtersToQ emitted `path:<folder>` for any non-root folder, but
PhotoPrism's `path:` operator is exact-by-default — so picking the
"2024" node in the folder tree returned zero hits when all photos
lived in date-stamped sub-folders (`2024/01`, `2024/02`, …). PP's
indexer always nests photos under YYYY/MM, so every year-level
folder was empty in the timeline.

PhotoPrism supports a trailing `*` wildcard, so emit
`path:"<folder>*"` instead:

  path:"2024*"     →  matches `2024`, `2024/01`, `2024/02/...`, …
  path:"2024/01*"  →  matches `2024/01` plus descendants — still
                      correct for a leaf folder.

Confirmed against the M0 instance: picking 2024 now returns the full
year's photos; 2024/01 still returns its direct contents.
This commit is contained in:
Claudio
2026-05-17 23:22:29 +02:00
parent e669e80a91
commit 8083328f2d

View File

@@ -97,8 +97,20 @@ export function filtersToQ(f: FilterState = filters): string {
// express "exact root match" (path:"" / path:/ both fall back to "no // express "exact root match" (path:"" / path:/ both fall back to "no
// filter"), so we leave the server query unfiltered and let the // filter"), so we leave the server query unfiltered and let the
// timeline post-filter to `Path === ''` client-side. // timeline post-filter to `Path === ''` client-side.
//
// For any non-root folder we want EVERY photo under that subtree, not
// just photos whose `photo_path` is an exact match. PhotoPrism's
// `path:` operator is exact-by-default but supports a trailing `*`
// wildcard:
// path:"2024" → matches only photos directly at `2024/` (none,
// if all files live in date-stamped sub-folders)
// path:"2024*" → matches `2024`, `2024/01`, `2024/02/...`, etc.
// path:"2024/01*" → matches `2024/01` plus descendants — still
// correct for a leaf folder.
// Always append `*` so internal tree nodes return the union of all
// descendant photos and leaves keep returning their direct contents.
if (f.folderPath && f.folderPath !== '/') { if (f.folderPath && f.folderPath !== '/') {
parts.push(`path:${quoteIfNeeded(f.folderPath)}`); parts.push(`path:${quoteIfNeeded(f.folderPath + '*')}`);
} }
if (f.search) parts.push(quoteIfNeeded(f.search)); if (f.search) parts.push(quoteIfNeeded(f.search));
return parts.join(' '); return parts.join(' ');