From 7197d6b651f541bcd19458b0a54e571bb2060d4a Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 4 Sep 2023 12:28:41 +0200 Subject: [PATCH] Search: Group stacked files with same diff when sorting by similarity. Diff is a perceptual differential hash. Grouping by photo ID should prevent stacks of related files from being split in search results. Signed-off-by: Michael Mayer --- internal/search/photos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/search/photos.go b/internal/search/photos.go index 6a7cf3040..13113f77e 100644 --- a/internal/search/photos.go +++ b/internal/search/photos.go @@ -156,7 +156,7 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string) s = s.Order("files.photo_taken_at, files.media_id") case sortby.Similar: s = s.Where("files.file_diff > 0") - s = s.Order("photos.photo_color, photos.cell_id, files.file_diff, files.time_index") + s = s.Order("photos.photo_color, photos.cell_id, files.file_diff, files.photo_id, files.time_index") case sortby.Name: s = s.Order("photos.photo_path, photos.photo_name, files.time_index") case sortby.Random: