mirror of
https://github.com/owncloud/ocis.git
synced 2026-10-23 23:29:02 +03:00
Add GPS location support to WebDAV search results
- Add location field mappings with Store=true in Bleve index - Rename properties to oc:photo-location-* for consistency - Add altitude support alongside latitude/longitude - Requires index rebuild to take effect
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -62,3 +62,5 @@ go.work
|
||||
go.work.sum
|
||||
.env
|
||||
.envrc
|
||||
CLAUDE.md
|
||||
.claude/
|
||||
|
||||
@@ -110,6 +110,16 @@ func BuildBleveMapping() (mapping.IndexMapping, error) {
|
||||
photoMapping.AddFieldMappingsAt("takenDateTime", photoDateMapping)
|
||||
docMapping.AddSubDocumentMapping("photo", photoMapping)
|
||||
|
||||
// Add explicit Location field mappings to ensure fields are stored
|
||||
locationMapping := bleve.NewDocumentMapping()
|
||||
locationNumericMapping := bleve.NewNumericFieldMapping()
|
||||
locationNumericMapping.Store = true
|
||||
locationNumericMapping.Index = true
|
||||
locationMapping.AddFieldMappingsAt("latitude", locationNumericMapping)
|
||||
locationMapping.AddFieldMappingsAt("longitude", locationNumericMapping)
|
||||
locationMapping.AddFieldMappingsAt("altitude", locationNumericMapping)
|
||||
docMapping.AddSubDocumentMapping("location", locationMapping)
|
||||
|
||||
indexMapping := bleve.NewIndexMapping()
|
||||
indexMapping.DefaultAnalyzer = keyword.Name
|
||||
indexMapping.DefaultMapping = docMapping
|
||||
|
||||
@@ -233,10 +233,13 @@ func matchToPropResponse(ctx context.Context, match *searchmsg.Match, hrefPrefix
|
||||
// Add location metadata if available
|
||||
if match.Entity.Location != nil {
|
||||
if match.Entity.Location.Latitude != nil {
|
||||
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:location-latitude", strconv.FormatFloat(*match.Entity.Location.Latitude, 'f', 6, 64)))
|
||||
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:photo-location-latitude", strconv.FormatFloat(*match.Entity.Location.Latitude, 'f', 6, 64)))
|
||||
}
|
||||
if match.Entity.Location.Longitude != nil {
|
||||
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:location-longitude", strconv.FormatFloat(*match.Entity.Location.Longitude, 'f', 6, 64)))
|
||||
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:photo-location-longitude", strconv.FormatFloat(*match.Entity.Location.Longitude, 'f', 6, 64)))
|
||||
}
|
||||
if match.Entity.Location.Altitude != nil {
|
||||
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:photo-location-altitude", strconv.FormatFloat(*match.Entity.Location.Altitude, 'f', 1, 64)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user