@@ -2,15 +2,16 @@ package search
22
33import (
44 "fmt"
5+ "path"
56 "strings"
67 "time"
78
89 "github.com/dustin/go-humanize/english"
9-
1010 "github.com/jinzhu/gorm"
1111
1212 "github.com/photoprism/photoprism/internal/entity"
1313 "github.com/photoprism/photoprism/internal/form"
14+ "github.com/photoprism/photoprism/pkg/fs"
1415 "github.com/photoprism/photoprism/pkg/rnd"
1516 "github.com/photoprism/photoprism/pkg/txt"
1617)
@@ -370,13 +371,19 @@ func Photos(f form.PhotoSearch) (results PhotoResults, count int, err error) {
370371 }
371372 }
372373
373- // Filter by main file name.
374+ // Filter by primary file name without path and extension .
374375 if f .Name != "" {
375- where , values := OrLike ("photos.photo_name" , f .Name )
376- s = s .Where (where , values ... )
376+ where , names := OrLike ("photos.photo_name" , f .Name )
377+
378+ // Omit file path and known extensions.
379+ for i := range names {
380+ names [i ] = fs .StripKnownExt (path .Base (names [i ].(string )))
381+ }
382+
383+ s = s .Where (where , names ... )
377384 }
378385
379- // Filter by actual file name .
386+ // Filter by complete file names .
380387 if f .Filename != "" {
381388 where , values := OrLike ("files.file_name" , f .Filename )
382389 s = s .Where (where , values ... )
0 commit comments