Skip to content

feat(server): Add album filter to search - #18985

Merged
mertalev merged 10 commits into
immich-app:mainfrom
xCJPECKOVERx:feat/search-filter-album/server
Jun 9, 2025
Merged

mertalev merged 10 commits into
immich-app:mainfrom
xCJPECKOVERx:feat/search-filter-album/server

Conversation

@xCJPECKOVERx

@xCJPECKOVERx xCJPECKOVERx commented Jun 7, 2025 •

Copy link
Copy Markdown
Collaborator

Description

Adds an album filter to the search repository's searchAssetBuilder. The filter's albumIds behave like OR (photos within any of the selected albums). When albums are supplied, the isNotInAlbum filter is skipped.
Updated smart, metadata, and random search dtos, and applied open-api updates for dart & web dtos.

I have the web part built and will submit a separate PR once this is merged.

How Has This Been Tested?

Added the web front end to test search. Selecting albums from the albums search filter reduces search results to only those included in the albums

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

- added inAlbums to search builder
- only check isNotInAlbum if albumIds is blank/empty
Comment on lines +232 to +240
return qb.innerJoin(
(eb) =>
eb
.selectFrom('albums_assets_assets')
.select('assetsId')
.where('albumsId', '=', anyUuid(albumIds!))
.groupBy('assetsId')
.as('has_album'),
(join) => join.onRef('has_album.assetsId', '=', 'assets.id'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where exists syntax should be faster than the comparatively expensive group by

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think it can actually be removed entirely; no need for it really without the HAVING...

@danieldietzler

Copy link
Copy Markdown
Member

The filter's albumIds behave like OR

I am not sure I like that. I get that it makes more sense for your specific use case, but for the tags multi-select it's currently an AND. I agree that we ideally want both, which is the overarching larger goal that has been discussed on Discord, but I'm not a fan of having different semantics for (visually) similar multi-selects.

@xCJPECKOVERx

Copy link
Copy Markdown
Collaborator Author

Fair enough, I'll update it to AND 👍

@xCJPECKOVERx

Copy link
Copy Markdown
Collaborator Author

Updated, however brought back the GROUP BY HAVING, since it's the same mechanism used by all the other relationship filters (tags, people, etc).
@mertalev I could take a look at refactoring all the filters to avoid GROUP BY, if that's where you were leaning? Probably a separate PR though.

@mertalev

mertalev commented Jun 7, 2025

Copy link
Copy Markdown
Member

Happy to see what you can come up with! It can be a separate PR, yes

@xCJPECKOVERx

Copy link
Copy Markdown
Collaborator Author

Sounds good. No promises lol! Haven't had to work on building queries since college basically.

@Idan37S

Idan37S commented Jan 31, 2026

Copy link
Copy Markdown

Is this feature been implemented and available in Immich?
I couldn't find it in the app

@xCJPECKOVERx

Copy link
Copy Markdown
Collaborator Author

Is this feature been implemented and available in Immich?

The ui portions haven't been merged in yet.

@Idan37S

Idan37S commented Feb 4, 2026

Copy link
Copy Markdown

Thanks for the response.

Are they planned to be merged or is it something that was dropped?
If yes, when do we expect to see this great UI feature? i'm really waiting for it :)

@xCJPECKOVERx

Copy link
Copy Markdown
Collaborator Author

No timelines unfortunately. It's quite out of date so will need time to rebase, however there were some blockers on the current implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants