Skip to content

feat: make photo title searchable (any_text + title: prefix) - #1162

Open
cat101 wants to merge 2 commits into
bpatrik:masterfrom
cat101:feat/title-search
Open

feat: make photo title searchable (any_text + title: prefix)#1162
cat101 wants to merge 2 commits into
bpatrik:masterfrom
cat101:feat/title-search

Conversation

@cat101

@cat101 cat101 commented Jun 7, 2026

Copy link
Copy Markdown

As with my other PRs, this has been generated using AI. This one is really a small missing feature. I have manually tested it on my environment.


Problem

Photo titles (Xmp.dc.title / IPTC ObjectName / Photoshop Headline / acdsee.caption) are extracted by MetadataLoader.mapTitle and stored on media.metadata.title — but SearchManager never consults that column. Titles set in digiKam et al. are loaded into the DB and shown in the info panel (added in #798), yet are invisible to search: a bare word in the search box doesn't find them, and there's no title: prefix.

Reproducer: tag a photo with title "Shuttle" in digiKam → re-index → search "Shuttle" → no results.

Fix

Add a SearchQueryTypes.title text-search type alongside the existing caption / file_name / etc., wired into:

  • SearchManager — new autocomplete branch + new where-builder clause on media.metadata.title, mirroring the existing caption clause. The negated branch wraps the predicate in a Brackets that also matches IS NULL, since title is sparse and NULL NOT LIKE 'x' is NULL under three-valued logic (would otherwise drop untitled photos from negated any_text results).
  • SearchQueryParsertitle in QueryKeywords + defaultQueryKeywords ('title') + stringify switch. Parsing auto-picks up the prefix because it iterates TextSearchQueryTypes.
  • AutoCompleteItemsPerCategoryConfig.title (default 3) — matches caption.
  • FrontendEnumTranslations label + autocomplete icon (reuses ionTextOutline).

any_text now also matches media.metadata.title, fixing the original bug. The DB schema already has the title column (added in #798), so no migration is required.

Tests

  • SearchQueryParser round-trip for title type.
  • SearchManager — new it('as title'): asserts both title:Shuttle (explicit) and any_text:Shuttle (the bug fix) return the seeded photo.
  • TestHelper.getPhotoEntry2 (sw2.jpg) gets metadata.title = 'Shuttle'. Picked because "Shuttle" contains no substring exercised by existing autocomplete assertions (tat, star, wars, phantom, arch, wa, a, sw, han) so no other test had to be updated.

Notes

  • Diff: 9 files, +101/−1. No new dependencies. No schema migration.
  • Backwards-compatible: existing search behavior unchanged when title is empty/NULL.
  • The IS NULL handling in the negate branch is a stricter pattern than the existing caption clause uses — caption has the same latent NULL bug, but I left it alone to keep the diff minimal and focused. Happy to file a follow-up if you want it normalized.
  • Frontend i18n: only the English label was added ($localize\Title``). The .xlf translation files would need a follow-up pass.

@cat101
cat101 force-pushed the feat/title-search branch from 290866f to aafbfc2 Compare June 7, 2026 15:30
@bpatrik

bpatrik commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Thanks!

please add the new filed to the content wrapper also with proper alias.

Also please merge as I did some significant changes to the search manager recently

cat101 added 2 commits June 7, 2026 21:03
Photo titles (Xmp.dc.title / IPTC ObjectName / Headline / acdsee caption)
are extracted by MetadataLoader and stored on media.metadata.title, but the
SearchManager never consulted that column — so titles set in digiKam et al.
were loaded into the DB and shown in the info panel but invisible to search.

This adds a SearchQueryTypes.title text-search type alongside the existing
caption/file_name/etc., wires it into:
- SearchManager (autocomplete + where-builder, mirroring the caption clause)
- SearchQueryParser (title: prefix, parse + stringify)
- AutoCompleteItemsPerCategoryConfig.title (default 3, mirroring caption)
- frontend EnumTranslations + autocomplete icon

any_text now also matches media.metadata.title, fixing the original bug
(plain words don't find photos by title).

Tests:
- SearchQueryParser round-trip for title type
- SearchManager 'as title': explicit title:Shuttle + bare any_text:Shuttle
- TestHelper getPhotoEntry2 gets metadata.title = 'Shuttle' as the fixture
Wrap the title LIKE clause in a Brackets predicate that also matches
'media.metadata.title IS NULL' when the query is negated. Without this,
photos with no title (the common case) are excluded from negated any_text
results because NULL NOT LIKE 'x' evaluates to NULL (three-valued logic),
which fails the AND-chain that negation builds.

Mirrors the existing pattern used for array fields (keywords/persons) at
matchArrayField — text-typed sparse fields need the same treatment.
@cat101
cat101 force-pushed the feat/title-search branch from aafbfc2 to d08e720 Compare June 8, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants