diff --git a/server/src/entities/asset.entity.ts b/server/src/entities/asset.entity.ts index ed9ac284fe..4ed74acec7 100644 --- a/server/src/entities/asset.entity.ts +++ b/server/src/entities/asset.entity.ts @@ -400,7 +400,7 @@ export function searchAssetBuilder(kysely: Kysely, options: AssetSearchBuild .$if(!!options.withExif, withExifInner) .$if(!!(options.withFaces || options.withPeople || options.personIds), (qb) => qb.select(withFacesAndPeople)) .$if(!options.withDeleted, (qb) => qb.where('assets.deletedAt', 'is', null)) - .$if(!options.withNullLocalDateTime, (qb) => qb.where('assets.localDateTime', 'is not', null)) + .$if(!options.withNullFileModifiedAt, (qb) => qb.where('assets.fileModifiedAt', 'is not', null)) .$if(!options.withNullFileCreatedAt, (qb) => qb.where('assets.fileCreatedAt', 'is not', null)) - .$if(!options.withNullFileModifiedAt, (qb) => qb.where('assets.fileModifiedAt', 'is not', null)); + .$if(!options.withNullLocalDateTime, (qb) => qb.where('assets.localDateTime', 'is not', null)); } diff --git a/server/src/queries/search.repository.sql b/server/src/queries/search.repository.sql index add98d57ad..490568847f 100644 --- a/server/src/queries/search.repository.sql +++ b/server/src/queries/search.repository.sql @@ -13,6 +13,9 @@ where and "assets"."isFavorite" = $4 and "assets"."isArchived" = $5 and "assets"."deletedAt" is null + and "assets"."fileModifiedAt" is not null + and "assets"."fileCreatedAt" is not null + and "assets"."localDateTime" is not null order by "assets"."fileCreatedAt" desc limit @@ -34,6 +37,9 @@ offset and "assets"."isFavorite" = $4 and "assets"."isArchived" = $5 and "assets"."deletedAt" is null + and "assets"."fileModifiedAt" is not null + and "assets"."fileCreatedAt" is not null + and "assets"."localDateTime" is not null and "assets"."id" < $6 order by random() @@ -54,6 +60,9 @@ union all and "assets"."isFavorite" = $11 and "assets"."isArchived" = $12 and "assets"."deletedAt" is null + and "assets"."fileModifiedAt" is not null + and "assets"."fileCreatedAt" is not null + and "assets"."localDateTime" is not null and "assets"."id" > $13 order by random() @@ -77,6 +86,9 @@ where and "assets"."isFavorite" = $4 and "assets"."isArchived" = $5 and "assets"."deletedAt" is null + and "assets"."fileModifiedAt" is not null + and "assets"."fileCreatedAt" is not null + and "assets"."localDateTime" is not null order by smart_search.embedding <=> $6 limit