Skip to content

Commit 76d98d9

Browse files
committed
feat(search): index and expose the video facet
1 parent 5e4f124 commit 76d98d9

16 files changed

Lines changed: 814 additions & 86 deletions

File tree

protogen/gen/opencloud/messages/search/v0/search.pb.go

Lines changed: 265 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protogen/gen/opencloud/messages/search/v0/search.pb.web.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protogen/gen/opencloud/services/search/v0/search.swagger.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@
298298
"items": {
299299
"type": "string"
300300
}
301+
},
302+
"video": {
303+
"$ref": "#/definitions/v0Video"
301304
}
302305
}
303306
},
@@ -531,6 +534,49 @@
531534
"format": "int32"
532535
}
533536
}
537+
},
538+
"v0Video": {
539+
"type": "object",
540+
"properties": {
541+
"audioBitsPerSample": {
542+
"type": "integer",
543+
"format": "int32"
544+
},
545+
"audioChannels": {
546+
"type": "integer",
547+
"format": "int32"
548+
},
549+
"audioFormat": {
550+
"type": "string"
551+
},
552+
"audioSamplesPerSecond": {
553+
"type": "integer",
554+
"format": "int32"
555+
},
556+
"bitrate": {
557+
"type": "integer",
558+
"format": "int32"
559+
},
560+
"duration": {
561+
"type": "string",
562+
"format": "int64"
563+
},
564+
"fourCC": {
565+
"type": "string"
566+
},
567+
"frameRate": {
568+
"type": "number",
569+
"format": "double"
570+
},
571+
"height": {
572+
"type": "integer",
573+
"format": "int32"
574+
},
575+
"width": {
576+
"type": "integer",
577+
"format": "int32"
578+
}
579+
}
534580
}
535581
},
536582
"externalDocs": {

protogen/proto/opencloud/messages/search/v0/search.proto

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ message Photo {
5959
optional google.protobuf.Timestamp takenDateTime = 9;
6060
}
6161

62+
message Video {
63+
optional int32 audioBitsPerSample = 1;
64+
optional int32 audioChannels = 2;
65+
optional string audioFormat = 3;
66+
optional int32 audioSamplesPerSecond = 4;
67+
optional int32 bitrate = 5;
68+
optional int64 duration = 6;
69+
optional string fourCC = 7;
70+
optional double frameRate = 8;
71+
optional int32 height = 9;
72+
optional int32 width = 10;
73+
}
74+
6275
message Entity {
6376
Reference ref = 1;
6477
ResourceID id = 2;
@@ -80,6 +93,7 @@ message Entity {
8093
Image image = 18;
8194
Photo photo = 19;
8295
repeated string favorites = 20;
96+
Video video = 22;
8397
}
8498

8599
message Match {

services/graph/pkg/service/v0/driveitems.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ func cs3ResourceToDriveItem(logger *log.Logger, publicBaseURL *url.URL, res *sto
456456
driveItem.Image = metadataToFacet[libregraph.Image](metadata, "image")
457457
driveItem.Location = metadataToFacet[libregraph.GeoCoordinates](metadata, "location")
458458
driveItem.Photo = metadataToFacet[libregraph.Photo](metadata, "photo")
459+
driveItem.Video = metadataToFacet[libregraph.Video](metadata, "video")
459460
}
460461

461462
return driveItem, nil

services/search/pkg/bleve/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func (b *Backend) Search(_ context.Context, sir *searchService.SearchIndexReques
139139
Image: hitToFacet[searchMessage.Image](hit.Fields, "image"),
140140
Location: hitToFacet[searchMessage.GeoCoordinates](hit.Fields, "location"),
141141
Photo: hitToFacet[searchMessage.Photo](hit.Fields, "photo"),
142+
Video: hitToFacet[searchMessage.Video](hit.Fields, "video"),
142143
},
143144
}
144145

services/search/pkg/bleve/testdata/mapping.golden.json

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,194 @@
934934
]
935935
}
936936
}
937+
},
938+
"video": {
939+
"enabled": true,
940+
"dynamic": true,
941+
"properties": {
942+
"audioBitsPerSample": {
943+
"enabled": true,
944+
"dynamic": true,
945+
"fields": [
946+
{
947+
"type": "number",
948+
"store": true,
949+
"index": true,
950+
"include_in_all": true,
951+
"docvalues": true
952+
}
953+
]
954+
},
955+
"audioChannels": {
956+
"enabled": true,
957+
"dynamic": true,
958+
"fields": [
959+
{
960+
"type": "number",
961+
"store": true,
962+
"index": true,
963+
"include_in_all": true,
964+
"docvalues": true
965+
}
966+
]
967+
},
968+
"audioFormat": {
969+
"enabled": true,
970+
"dynamic": true,
971+
"fields": [
972+
{
973+
"type": "text",
974+
"analyzer": "keyword",
975+
"store": true,
976+
"index": true,
977+
"include_term_vectors": true,
978+
"include_in_all": true,
979+
"docvalues": true
980+
}
981+
]
982+
},
983+
"audioFormat_lowercase": {
984+
"enabled": true,
985+
"dynamic": true,
986+
"fields": [
987+
{
988+
"type": "text",
989+
"analyzer": "keyword",
990+
"index": true,
991+
"include_term_vectors": true
992+
}
993+
]
994+
},
995+
"audioFormat_words": {
996+
"enabled": true,
997+
"dynamic": true,
998+
"fields": [
999+
{
1000+
"type": "text",
1001+
"analyzer": "words",
1002+
"index": true,
1003+
"include_term_vectors": true
1004+
}
1005+
]
1006+
},
1007+
"audioSamplesPerSecond": {
1008+
"enabled": true,
1009+
"dynamic": true,
1010+
"fields": [
1011+
{
1012+
"type": "number",
1013+
"store": true,
1014+
"index": true,
1015+
"include_in_all": true,
1016+
"docvalues": true
1017+
}
1018+
]
1019+
},
1020+
"bitrate": {
1021+
"enabled": true,
1022+
"dynamic": true,
1023+
"fields": [
1024+
{
1025+
"type": "number",
1026+
"store": true,
1027+
"index": true,
1028+
"include_in_all": true,
1029+
"docvalues": true
1030+
}
1031+
]
1032+
},
1033+
"duration": {
1034+
"enabled": true,
1035+
"dynamic": true,
1036+
"fields": [
1037+
{
1038+
"type": "number",
1039+
"store": true,
1040+
"index": true,
1041+
"include_in_all": true,
1042+
"docvalues": true
1043+
}
1044+
]
1045+
},
1046+
"fourCC": {
1047+
"enabled": true,
1048+
"dynamic": true,
1049+
"fields": [
1050+
{
1051+
"type": "text",
1052+
"analyzer": "keyword",
1053+
"store": true,
1054+
"index": true,
1055+
"include_term_vectors": true,
1056+
"include_in_all": true,
1057+
"docvalues": true
1058+
}
1059+
]
1060+
},
1061+
"fourCC_lowercase": {
1062+
"enabled": true,
1063+
"dynamic": true,
1064+
"fields": [
1065+
{
1066+
"type": "text",
1067+
"analyzer": "keyword",
1068+
"index": true,
1069+
"include_term_vectors": true
1070+
}
1071+
]
1072+
},
1073+
"fourCC_words": {
1074+
"enabled": true,
1075+
"dynamic": true,
1076+
"fields": [
1077+
{
1078+
"type": "text",
1079+
"analyzer": "words",
1080+
"index": true,
1081+
"include_term_vectors": true
1082+
}
1083+
]
1084+
},
1085+
"frameRate": {
1086+
"enabled": true,
1087+
"dynamic": true,
1088+
"fields": [
1089+
{
1090+
"type": "number",
1091+
"store": true,
1092+
"index": true,
1093+
"include_in_all": true,
1094+
"docvalues": true
1095+
}
1096+
]
1097+
},
1098+
"height": {
1099+
"enabled": true,
1100+
"dynamic": true,
1101+
"fields": [
1102+
{
1103+
"type": "number",
1104+
"store": true,
1105+
"index": true,
1106+
"include_in_all": true,
1107+
"docvalues": true
1108+
}
1109+
]
1110+
},
1111+
"width": {
1112+
"enabled": true,
1113+
"dynamic": true,
1114+
"fields": [
1115+
{
1116+
"type": "number",
1117+
"store": true,
1118+
"index": true,
1119+
"include_in_all": true,
1120+
"docvalues": true
1121+
}
1122+
]
1123+
}
1124+
}
9371125
}
9381126
}
9391127
},

services/search/pkg/content/content.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Document struct {
2727
Image *libregraph.Image `json:"image,omitempty"`
2828
Location *libregraph.GeoCoordinates `json:"location,omitempty"`
2929
Photo *libregraph.Photo `json:"photo,omitempty"`
30+
Video *libregraph.Video `json:"video,omitempty"`
3031
}
3132

3233
func CleanString(content, langCode string) string {

services/search/pkg/content/tika.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func (t Tika) Extract(ctx context.Context, ri *provider.ResourceInfo) (Document,
112112
if v := t.getAudio(meta); v != nil {
113113
doc.Audio = v
114114
}
115+
if v := t.getVideo(meta); v != nil {
116+
doc.Video = v
117+
}
115118
}
116119

117120
if langCode := t.detectLanguage(ctx, doc.Content); langCode != "" && t.CleanStopWords {

services/search/pkg/content/tika_image.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ package content
22

33
import (
44
"strconv"
5+
"strings"
56

67
libregraph "github.com/opencloud-eu/libre-graph-api-go"
78
)
89

910
func (t Tika) getImage(meta map[string][]string) *libregraph.Image {
11+
// tiff:ImageWidth/Length are also set for videos; the content type is what
12+
// tells an image apart.
13+
if ct, err := getFirstValue(meta, "Content-Type"); err != nil || !strings.HasPrefix(ct, "image/") {
14+
return nil
15+
}
16+
1017
var image *libregraph.Image
1118
initImage := func() {
1219
if image == nil {

0 commit comments

Comments
 (0)