Skip to content

Commit

Permalink
fix(server): add more conditions to smart search (immich-app#5806)
Browse files Browse the repository at this point in the history
* add more asset conditions

* udpate sql
  • Loading branch information
mertalev authored Dec 18, 2023
1 parent 6e7b3d6 commit b520955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions server/src/infra/repositories/smart-info.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export class SmartInfoRepository implements ISmartInfoRepository {
.createQueryBuilder(AssetEntity, 'a')
.innerJoin('a.smartSearch', 's')
.where('a.ownerId = :ownerId')
.andWhere('a.isVisible = true')
.andWhere('a.isArchived = false')
.andWhere('a.fileCreatedAt < NOW()')
.leftJoinAndSelect('a.exifInfo', 'e')
.orderBy('s.embedding <=> :embedding')
.setParameters({ ownerId, embedding: asVector(embedding) })
Expand Down
7 changes: 6 additions & 1 deletion server/src/infra/sql/smart.info.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ FROM
INNER JOIN "smart_search" "s" ON "s"."assetId" = "a"."id"
LEFT JOIN "exif" "e" ON "e"."assetId" = "a"."id"
WHERE
("a"."ownerId" = $1)
(
"a"."ownerId" = $1
AND "a"."isVisible" = true
AND "a"."isArchived" = false
AND "a"."fileCreatedAt" < NOW()
)
AND ("a"."deletedAt" IS NULL)
ORDER BY
"s"."embedding" <= > $2 ASC
Expand Down

0 comments on commit b520955

Please sign in to comment.