Search: Find pictures by Exif UID, XMP Document ID or Instance ID #3035

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-12-28 17:50:08 +01:00
parent a7ec039337
commit b38dac8e8c
4 changed files with 22 additions and 2 deletions

View file

@ -11,7 +11,8 @@ type SearchPhotos struct {
Query string `form:"q"`
Scope string `form:"s" serialize:"-" example:"s:ariqwb43p5dh9h13" notes:"Limits the results to one album or another scope, if specified"`
Filter string `form:"filter" serialize:"-" notes:"-"`
UID string `form:"uid" example:"uid:pqbcf5j446s0futy" notes:"Search for specific files or photos, only exact matches"`
ID string `form:"id" example:"id:123e4567-e89b-..." notes:"Finds pictures by Exif UID, XMP Document ID or Instance ID"`
UID string `form:"uid" example:"uid:pqbcf5j446s0futy" notes:"Limits results to the specified internal unique IDs"`
Type string `form:"type" example:"type:raw" notes:"Media Type (image, video, raw, live, animated); OR search with |"`
Path string `form:"path" example:"path:2020/Holiday" notes:"Path Name, OR search with |, supports * wildcards"`
Folder string `form:"folder" example:"folder:\"*/2020\"" notes:"Path Name, OR search with |, supports * wildcards"` // Alias for Path

View file

@ -11,7 +11,8 @@ type SearchPhotosGeo struct {
Query string `form:"q"`
Scope string `form:"s" serialize:"-" example:"s:ariqwb43p5dh9h13" notes:"Limits the results to one album or another scope, if specified"`
Filter string `form:"filter" serialize:"-" notes:"-"`
UID string `form:"uid" example:"uid:pqbcf5j446s0futy" notes:"Search for specific files or photos, only exact matches"`
ID string `form:"id" example:"id:123e4567-e89b-..." notes:"Finds pictures by Exif UID, XMP Document ID or Instance ID"`
UID string `form:"uid" example:"uid:pqbcf5j446s0futy" notes:"Limits results to the specified internal unique IDs"`
Near string `form:"near"`
Type string `form:"type"`
Path string `form:"path"`

View file

@ -217,6 +217,15 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
}
}
// Find Unique Image ID (Exif), Document ID, or Instance ID (XMP)?
if txt.NotEmpty(f.ID) {
for _, id := range SplitAnd(strings.ToLower(f.ID)) {
if ids := SplitOr(id); len(ids) > 0 {
s = s.Where("files.instance_id IN (?) OR photos.uuid IN (?)", ids, ids)
}
}
}
// Filter by label, label category and keywords.
var categories []entity.Category
var labels []entity.Label

View file

@ -175,6 +175,15 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes
}
}
// Find Unique Image ID (Exif), Document ID, or Instance ID (XMP)?
if txt.NotEmpty(f.ID) {
for _, id := range SplitAnd(strings.ToLower(f.ID)) {
if ids := SplitOr(id); len(ids) > 0 {
s = s.Where("files.instance_id IN (?) OR photos.uuid IN (?)", ids, ids)
}
}
}
// Set search filters based on search terms.
if terms := txt.SearchTerms(f.Query); f.Query != "" && len(terms) == 0 {
if f.Title == "" {