From 6c06b8edb61455768c1283e08089f416e0a9dcd2 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Fri, 27 Oct 2023 09:19:11 +0200 Subject: [PATCH 1/5] add file type filter chip --- .../unreleased/add-file-type-filter-chip.md | 6 + services/frontend/pkg/revaconfig/config.go | 3 +- services/search/pkg/query/bleve/compiler.go | 98 +++++++++- .../search/pkg/query/bleve/compiler_test.go | 168 ++++++++++++++++++ 4 files changed, 273 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/add-file-type-filter-chip.md diff --git a/changelog/unreleased/add-file-type-filter-chip.md b/changelog/unreleased/add-file-type-filter-chip.md new file mode 100644 index 00000000000..707c958ad50 --- /dev/null +++ b/changelog/unreleased/add-file-type-filter-chip.md @@ -0,0 +1,6 @@ +Enhancement: Add "File type" filter Chip + +Add "File type" filter Chip + +https://github.com/owncloud/ocis/pull/7602 +https://github.com/owncloud/ocis/issues/7432 diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index 360e7aff6f5..3aee0057da2 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -303,7 +303,8 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string "enabled": false, }, "mimetype": map[string]interface{}{ - "enabled": true, + "keywords": []string{"file", "folder", "documents", "spreadsheets", "presentations", "pdfs", "images", "videos", "audio", "archives"}, + "enabled": true, }, "type": map[string]interface{}{ "enabled": true, diff --git a/services/search/pkg/query/bleve/compiler.go b/services/search/pkg/query/bleve/compiler.go index c7b1c70d821..028af547b8e 100644 --- a/services/search/pkg/query/bleve/compiler.go +++ b/services/search/pkg/query/bleve/compiler.go @@ -95,7 +95,18 @@ func walk(offset int, nodes []ast.Node) (bleveQuery.Query, int, error) { v = strings.ToLower(v) } - q := bleveQuery.NewQueryStringQuery(k + ":" + v) + var q bleveQuery.Query + var group bool + switch k { + case "MimeType": + q, group = mimeType(k, v) + if prev == nil { + isGroup = group + } + default: + q = bleveQuery.NewQueryStringQuery(k + ":" + v) + } + if prev == nil { prev = q } else { @@ -232,9 +243,21 @@ func mapBinary(operator *ast.OperatorNode, ln, rn bleveQuery.Query, leftIsGroup } if operator.Value == kql.BoolOR { if left, ok := ln.(*bleveQuery.DisjunctionQuery); ok { + // if both are DisjunctionQuery then merge + if right, ok := rn.(*bleveQuery.DisjunctionQuery); ok { + left.AddQuery(right.Disjuncts...) + return left + } left.AddQuery(rn) return left } + if _, ok := ln.(*bleveQuery.ConjunctionQuery); !ok { + if right, ok := rn.(*bleveQuery.DisjunctionQuery); ok { + left := bleveQuery.NewDisjunctionQuery([]bleveQuery.Query{ln}) + left.AddQuery(right.Disjuncts...) + return left + } + } return bleveQuery.NewDisjunctionQuery([]bleveQuery.Query{ ln, rn, @@ -264,3 +287,76 @@ func normalizeGroupingProperty(group *ast.GroupNode) *ast.GroupNode { } return group } + +func mimeType(k, v string) (bleveQuery.Query, bool) { + switch v { + case "file": + q := bleve.NewBooleanQuery() + q.AddMustNot(bleveQuery.NewQueryStringQuery(k + ":httpd/unix-directory")) + return q, false + case "folder": + return bleveQuery.NewQueryStringQuery(k + ":httpd/unix-directory"), false + case "documents": + return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, + "application/msword", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "application/vnd.oasis.opendocument.text", + "text/plain", + "text/markdown", + "application/rtf", + "application/vnd.apple.pages", + )), true + case "spreadsheets": + return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, + "application/vnd.ms-excel", + "application/vnd.oasis.opendocument.spreadsheet", + "text/csv", + "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "application/vnd.oasis.opendocument.presentation", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.oasis.opendocument.spreadsheet", + "application/vnd.apple.numbers", + )), true + case "presentations": + return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, + "application/vnd.ms-excel", + "application/vnd.oasis.opendocument.spreadsheet", + "text/csv", + "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "application/vnd.oasis.opendocument.presentation", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.oasis.opendocument.spreadsheet", + "application/vnd.apple.numbers", + )), true + case "pdfs": + return bleveQuery.NewQueryStringQuery(k + ":application/pdf"), false + case "images": + return bleveQuery.NewQueryStringQuery(k + ":image/*"), false + case "videos": + return bleveQuery.NewQueryStringQuery(k + ":video/*"), false + case "audio": + return bleveQuery.NewQueryStringQuery(k + ":audio/*"), false + case "archives": + return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, + "application/zip", + "application/x-tar", + "application/x-gzip", + "application/x-7", + "z-compressed", + "application/x-rar-compressed", + "application/x-bzip2", + "application/x-bzip", + "application/x-tgz", + )), true + default: + return bleveQuery.NewQueryStringQuery(k + ":" + v), false + } +} + +func newQueryStringQueryList(k string, v ...string) []bleveQuery.Query { + list := make([]bleveQuery.Query, len(v)) + for i := 0; i < len(v); i++ { + list[i] = bleveQuery.NewQueryStringQuery(k + ":" + v[i]) + } + return list +} diff --git a/services/search/pkg/query/bleve/compiler_test.go b/services/search/pkg/query/bleve/compiler_test.go index 7a36b647dc2..82e4ce0ec12 100644 --- a/services/search/pkg/query/bleve/compiler_test.go +++ b/services/search/pkg/query/bleve/compiler_test.go @@ -120,6 +120,51 @@ func Test_compile(t *testing.T) { }), wantErr: false, }, + { + name: `a OR b AND c`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.StringNode{Value: "a"}, + &ast.OperatorNode{Value: "OR"}, + &ast.StringNode{Value: "b"}, + &ast.OperatorNode{Value: "AND"}, + &ast.StringNode{Value: "c"}, + }, + }, + want: query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`Name:a`), + query.NewConjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`Name:b`), + query.NewQueryStringQuery(`Name:c`), + }), + }), + wantErr: false, + }, + { + name: `(a OR b OR c) AND d`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.GroupNode{Nodes: []ast.Node{ + &ast.StringNode{Value: "a"}, + &ast.OperatorNode{Value: "OR"}, + &ast.StringNode{Value: "b"}, + &ast.OperatorNode{Value: "OR"}, + &ast.StringNode{Value: "c"}, + }}, + &ast.OperatorNode{Value: "AND"}, + &ast.StringNode{Value: "d"}, + }, + }, + want: query.NewConjunctionQuery([]query.Query{ + query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`Name:a`), + query.NewQueryStringQuery(`Name:b`), + query.NewQueryStringQuery(`Name:c`), + }), + query.NewQueryStringQuery(`Name:d`), + }), + wantErr: false, + }, { name: `(name:"moby di*" OR tag:bestseller) AND tag:book`, args: &ast.Ast{ @@ -341,6 +386,129 @@ func Test_compile(t *testing.T) { }), wantErr: false, }, + { + name: `MimeType:documents`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.StringNode{Key: "mimetype", Value: "documents"}, + }, + }, + want: query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`MimeType:application/msword`), + query.NewQueryStringQuery(`MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document`), + query.NewQueryStringQuery(`MimeType:application/vnd.oasis.opendocument.text`), + query.NewQueryStringQuery(`MimeType:text/plain`), + query.NewQueryStringQuery(`MimeType:text/markdown`), + query.NewQueryStringQuery(`MimeType:application/rtf`), + query.NewQueryStringQuery(`MimeType:application/vnd.apple.pages`), + }), + wantErr: false, + }, + { + name: `MimeType:documents AND *tdd*`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.OperatorNode{Value: "AND"}, + &ast.StringNode{Key: "name", Value: "*tdd*"}, + }, + }, + want: query.NewConjunctionQuery([]query.Query{ + query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`MimeType:application/msword`), + query.NewQueryStringQuery(`MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document`), + query.NewQueryStringQuery(`MimeType:application/vnd.oasis.opendocument.text`), + query.NewQueryStringQuery(`MimeType:text/plain`), + query.NewQueryStringQuery(`MimeType:text/markdown`), + query.NewQueryStringQuery(`MimeType:application/rtf`), + query.NewQueryStringQuery(`MimeType:application/vnd.apple.pages`), + }), + query.NewQueryStringQuery(`Name:*tdd*`), + }), + wantErr: false, + }, + { + name: `MimeType:documents OR MimeType:pdfs AND *tdd*`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.OperatorNode{Value: "OR"}, + &ast.StringNode{Key: "mimetype", Value: "pdfs"}, + &ast.OperatorNode{Value: "AND"}, + &ast.StringNode{Key: "name", Value: "*tdd*"}, + }, + }, + want: query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`MimeType:application/msword`), + query.NewQueryStringQuery(`MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document`), + query.NewQueryStringQuery(`MimeType:application/vnd.oasis.opendocument.text`), + query.NewQueryStringQuery(`MimeType:text/plain`), + query.NewQueryStringQuery(`MimeType:text/markdown`), + query.NewQueryStringQuery(`MimeType:application/rtf`), + query.NewQueryStringQuery(`MimeType:application/vnd.apple.pages`), + query.NewConjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`MimeType:application/pdf`), + query.NewQueryStringQuery(`Name:*tdd*`), + }), + }), + wantErr: false, + }, + { + name: `(MimeType:documents OR MimeType:pdfs) AND *tdd*`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.GroupNode{Nodes: []ast.Node{ + &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.OperatorNode{Value: "OR"}, + &ast.StringNode{Key: "mimetype", Value: "pdfs"}, + }}, + &ast.OperatorNode{Value: "AND"}, + &ast.StringNode{Key: "name", Value: "*tdd*"}, + }, + }, + want: query.NewConjunctionQuery([]query.Query{ + query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`MimeType:application/msword`), + query.NewQueryStringQuery(`MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document`), + query.NewQueryStringQuery(`MimeType:application/vnd.oasis.opendocument.text`), + query.NewQueryStringQuery(`MimeType:text/plain`), + query.NewQueryStringQuery(`MimeType:text/markdown`), + query.NewQueryStringQuery(`MimeType:application/rtf`), + query.NewQueryStringQuery(`MimeType:application/vnd.apple.pages`), + query.NewQueryStringQuery(`MimeType:application/pdf`), + }), + query.NewQueryStringQuery(`Name:*tdd*`), + }), + wantErr: false, + }, + { + name: `(MimeType:pdfs OR MimeType:documents) AND *tdd*`, + args: &ast.Ast{ + Nodes: []ast.Node{ + &ast.GroupNode{Nodes: []ast.Node{ + &ast.StringNode{Key: "mimetype", Value: "pdfs"}, + &ast.OperatorNode{Value: "OR"}, + &ast.StringNode{Key: "mimetype", Value: "documents"}, + }}, + &ast.OperatorNode{Value: "AND"}, + &ast.StringNode{Key: "name", Value: "*tdd*"}, + }, + }, + want: query.NewConjunctionQuery([]query.Query{ + query.NewDisjunctionQuery([]query.Query{ + query.NewQueryStringQuery(`MimeType:application/pdf`), + query.NewQueryStringQuery(`MimeType:application/msword`), + query.NewQueryStringQuery(`MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document`), + query.NewQueryStringQuery(`MimeType:application/vnd.oasis.opendocument.text`), + query.NewQueryStringQuery(`MimeType:text/plain`), + query.NewQueryStringQuery(`MimeType:text/markdown`), + query.NewQueryStringQuery(`MimeType:application/rtf`), + query.NewQueryStringQuery(`MimeType:application/vnd.apple.pages`), + }), + query.NewQueryStringQuery(`Name:*tdd*`), + }), + wantErr: false, + }, { name: `John Smith`, args: &ast.Ast{ From 2bb46d7330663b62ef7e470b09548a1393d71a75 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Tue, 7 Nov 2023 15:43:54 +0100 Subject: [PATCH 2/5] changed the keyword --- .../unreleased/add-file-type-filter-chip.md | 86 ++++++++++++++++++- go.mod | 2 +- go.sum | 4 +- services/frontend/pkg/revaconfig/config.go | 2 +- services/search/pkg/query/bleve/compiler.go | 14 +-- .../search/pkg/query/bleve/compiler_test.go | 26 +++--- .../owncloud/ocs/data/capabilities.go | 24 +++--- vendor/modules.txt | 2 +- 8 files changed, 121 insertions(+), 39 deletions(-) diff --git a/changelog/unreleased/add-file-type-filter-chip.md b/changelog/unreleased/add-file-type-filter-chip.md index 707c958ad50..092a37e318a 100644 --- a/changelog/unreleased/add-file-type-filter-chip.md +++ b/changelog/unreleased/add-file-type-filter-chip.md @@ -1,6 +1,88 @@ -Enhancement: Add "File type" filter Chip +Enhancement: Add search mimetype filter -Add "File type" filter Chip +Add filter MimeType filter shortcuts to search for specific document types. +For example, a search query MimeType:documents will search for files with the following mimetypes: + +application/msword +MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document +MimeType:application/vnd.oasis.opendocument.text +MimeType:text/plain +MimeType:text/markdown +MimeType:application/rtf +MimeType:application/vnd.apple.pages + +besides the document shorthand, it also contains following: + +* file +* folder +* document +* spreadsheet +* presentation +* pdf +* image +* video +* audio +* archive + +## File + +## Folder + +## Document: + +application/msword +application/vnd.openxmlformats-officedocument.wordprocessingml.document +application/vnd.oasis.opendocument.text +text/plain +text/markdown +application/rtf +application/vnd.apple.pages + +## Spreadsheet: + +application/vnd.ms-excel +application/vnd.oasis.opendocument.spreadsheet +text/csv +application/vnd.openxmlformats-officedocument.presentationml.presentation +application/vnd.oasis.opendocument.presentation +application/vnd.openxmlformats-officedocument.spreadsheetml.sheet +application/vnd.oasis.opendocument.spreadsheet +application/vnd.apple.numbers + +## Presentations: + +application/vnd.ms-powerpoint +application/vnd.openxmlformats-officedocument.presentationml.presentation +application/vnd.oasis.opendocument.presentation +application/vnd.apple.keynote +application/vnd.ms-excel + +## PDF + +application/pdf + +## Image: + +image/* + +## Video: + +video/* + +## Audio: + +audio/* + +## Archive (zip ...): + +application/zip +application/x-tar +application/x-gzip +application/x-7z-compressed +application/x-rar-compressed +application/x-bzip2 +application/x-bzip +application/x-tgz https://github.com/owncloud/ocis/pull/7602 https://github.com/owncloud/ocis/issues/7432 diff --git a/go.mod b/go.mod index 2d4c86bbe23..67f4a19bc8a 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.7.0 github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 - github.com/cs3org/reva/v2 v2.16.1-0.20231107141341-4b08a8b754e7 + github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e diff --git a/go.sum b/go.sum index 61d1cef480d..7eb6de2f7c2 100644 --- a/go.sum +++ b/go.sum @@ -1013,8 +1013,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.16.1-0.20231107141341-4b08a8b754e7 h1:NmISK1T/c/1hDfOiGqPEVAOq3BTxWzIe2+bn3TtrzzU= -github.com/cs3org/reva/v2 v2.16.1-0.20231107141341-4b08a8b754e7/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= +github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f h1:WObbHWbihhh98V9tjjBUsIYKR3qIMDY0/9cve8KLWr4= +github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index 3aee0057da2..6dad0372b29 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -303,7 +303,7 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string "enabled": false, }, "mimetype": map[string]interface{}{ - "keywords": []string{"file", "folder", "documents", "spreadsheets", "presentations", "pdfs", "images", "videos", "audio", "archives"}, + "keywords": []string{"file", "folder", "document", "spreadsheet", "presentation", "pdf", "image", "video", "audio", "archive"}, "enabled": true, }, "type": map[string]interface{}{ diff --git a/services/search/pkg/query/bleve/compiler.go b/services/search/pkg/query/bleve/compiler.go index 028af547b8e..6b64844d344 100644 --- a/services/search/pkg/query/bleve/compiler.go +++ b/services/search/pkg/query/bleve/compiler.go @@ -296,7 +296,7 @@ func mimeType(k, v string) (bleveQuery.Query, bool) { return q, false case "folder": return bleveQuery.NewQueryStringQuery(k + ":httpd/unix-directory"), false - case "documents": + case "document": return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", @@ -306,7 +306,7 @@ func mimeType(k, v string) (bleveQuery.Query, bool) { "application/rtf", "application/vnd.apple.pages", )), true - case "spreadsheets": + case "spreadsheet": return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, "application/vnd.ms-excel", "application/vnd.oasis.opendocument.spreadsheet", @@ -317,7 +317,7 @@ func mimeType(k, v string) (bleveQuery.Query, bool) { "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.apple.numbers", )), true - case "presentations": + case "presentation": return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, "application/vnd.ms-excel", "application/vnd.oasis.opendocument.spreadsheet", @@ -328,15 +328,15 @@ func mimeType(k, v string) (bleveQuery.Query, bool) { "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.apple.numbers", )), true - case "pdfs": + case "pdf": return bleveQuery.NewQueryStringQuery(k + ":application/pdf"), false - case "images": + case "image": return bleveQuery.NewQueryStringQuery(k + ":image/*"), false - case "videos": + case "video": return bleveQuery.NewQueryStringQuery(k + ":video/*"), false case "audio": return bleveQuery.NewQueryStringQuery(k + ":audio/*"), false - case "archives": + case "archive": return bleveQuery.NewDisjunctionQuery(newQueryStringQueryList(k, "application/zip", "application/x-tar", diff --git a/services/search/pkg/query/bleve/compiler_test.go b/services/search/pkg/query/bleve/compiler_test.go index 82e4ce0ec12..0e8401b680d 100644 --- a/services/search/pkg/query/bleve/compiler_test.go +++ b/services/search/pkg/query/bleve/compiler_test.go @@ -387,10 +387,10 @@ func Test_compile(t *testing.T) { wantErr: false, }, { - name: `MimeType:documents`, + name: `MimeType:document`, args: &ast.Ast{ Nodes: []ast.Node{ - &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.StringNode{Key: "mimetype", Value: "document"}, }, }, want: query.NewDisjunctionQuery([]query.Query{ @@ -405,10 +405,10 @@ func Test_compile(t *testing.T) { wantErr: false, }, { - name: `MimeType:documents AND *tdd*`, + name: `MimeType:document AND *tdd*`, args: &ast.Ast{ Nodes: []ast.Node{ - &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.StringNode{Key: "mimetype", Value: "document"}, &ast.OperatorNode{Value: "AND"}, &ast.StringNode{Key: "name", Value: "*tdd*"}, }, @@ -428,12 +428,12 @@ func Test_compile(t *testing.T) { wantErr: false, }, { - name: `MimeType:documents OR MimeType:pdfs AND *tdd*`, + name: `MimeType:document OR MimeType:pdf AND *tdd*`, args: &ast.Ast{ Nodes: []ast.Node{ - &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.StringNode{Key: "mimetype", Value: "document"}, &ast.OperatorNode{Value: "OR"}, - &ast.StringNode{Key: "mimetype", Value: "pdfs"}, + &ast.StringNode{Key: "mimetype", Value: "pdf"}, &ast.OperatorNode{Value: "AND"}, &ast.StringNode{Key: "name", Value: "*tdd*"}, }, @@ -454,13 +454,13 @@ func Test_compile(t *testing.T) { wantErr: false, }, { - name: `(MimeType:documents OR MimeType:pdfs) AND *tdd*`, + name: `(MimeType:document OR MimeType:pdf) AND *tdd*`, args: &ast.Ast{ Nodes: []ast.Node{ &ast.GroupNode{Nodes: []ast.Node{ - &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.StringNode{Key: "mimetype", Value: "document"}, &ast.OperatorNode{Value: "OR"}, - &ast.StringNode{Key: "mimetype", Value: "pdfs"}, + &ast.StringNode{Key: "mimetype", Value: "pdf"}, }}, &ast.OperatorNode{Value: "AND"}, &ast.StringNode{Key: "name", Value: "*tdd*"}, @@ -482,13 +482,13 @@ func Test_compile(t *testing.T) { wantErr: false, }, { - name: `(MimeType:pdfs OR MimeType:documents) AND *tdd*`, + name: `(MimeType:pdf OR MimeType:document) AND *tdd*`, args: &ast.Ast{ Nodes: []ast.Node{ &ast.GroupNode{Nodes: []ast.Node{ - &ast.StringNode{Key: "mimetype", Value: "pdfs"}, + &ast.StringNode{Key: "mimetype", Value: "pdf"}, &ast.OperatorNode{Value: "OR"}, - &ast.StringNode{Key: "mimetype", Value: "documents"}, + &ast.StringNode{Key: "mimetype", Value: "document"}, }}, &ast.OperatorNode{Value: "AND"}, &ast.StringNode{Key: "name", Value: "*tdd*"}, diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go index a2a48f4917f..7718d2b2a07 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go @@ -69,15 +69,15 @@ type CapabilitiesSearch struct { // CapabilitiesSearchProperties holds the search property capabilities type CapabilitiesSearchProperties struct { - Name *CapabilitiesSearchProperty `json:"name" xml:"name" mapstructure:"name"` - Mtime *CapabilitiesSearchPropertyMtime `json:"mtime" xml:"mtime" mapstructure:"mtime"` - Size *CapabilitiesSearchProperty `json:"size" xml:"size" mapstructure:"size"` - Mimetype *CapabilitiesSearchProperty `json:"mimetype" xml:"mimetype" mapstructure:"mimetype"` - Type *CapabilitiesSearchProperty `json:"type" xml:"type" mapstructure:"type"` - Tag *CapabilitiesSearchProperty `json:"tag" xml:"tag" mapstructure:"tag"` - Tags *CapabilitiesSearchProperty `json:"tags" xml:"tags" mapstructure:"tags"` - Content *CapabilitiesSearchProperty `json:"content" xml:"content" mapstructure:"content"` - Scope *CapabilitiesSearchProperty `json:"scope" xml:"scope" mapstructure:"scope"` + Name *CapabilitiesSearchProperty `json:"name" xml:"name" mapstructure:"name"` + Mtime *CapabilitiesSearchPropertyExtended `json:"mtime" xml:"mtime" mapstructure:"mtime"` + Size *CapabilitiesSearchProperty `json:"size" xml:"size" mapstructure:"size"` + Mimetype *CapabilitiesSearchPropertyExtended `json:"mimetype" xml:"mimetype" mapstructure:"mimetype"` + Type *CapabilitiesSearchProperty `json:"type" xml:"type" mapstructure:"type"` + Tag *CapabilitiesSearchProperty `json:"tag" xml:"tag" mapstructure:"tag"` + Tags *CapabilitiesSearchProperty `json:"tags" xml:"tags" mapstructure:"tags"` + Content *CapabilitiesSearchProperty `json:"content" xml:"content" mapstructure:"content"` + Scope *CapabilitiesSearchProperty `json:"scope" xml:"scope" mapstructure:"scope"` } // CapabilitiesSearchProperty represents the default search property @@ -85,10 +85,10 @@ type CapabilitiesSearchProperty struct { Enabled bool `json:"enabled" xml:"enabled" mapstructure:"enabled"` } -// CapabilitiesSearchPropertyMtime represents the mtime search property -type CapabilitiesSearchPropertyMtime struct { +// CapabilitiesSearchPropertyExtended represents the extended search property +type CapabilitiesSearchPropertyExtended struct { CapabilitiesSearchProperty - Keywords []string `json:"keywords" xml:"keywords" mapstructure:"keywords"` + Keywords []string `json:"keywords,omitempty" xml:"keywords,omitempty" mapstructure:"keywords"` } // Spaces lets a service configure its advertised options related to Storage Spaces. diff --git a/vendor/modules.txt b/vendor/modules.txt index afd2dc39c37..8c39d041215 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -357,7 +357,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.16.1-0.20231107141341-4b08a8b754e7 +# github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime From 6e83e1ef96d19899bd6d1a860601d196779f4139 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Wed, 8 Nov 2023 16:27:56 +0100 Subject: [PATCH 3/5] use reva issue-7432-replace --- go.mod | 5 ++++- go.sum | 4 ++-- .../services/sharesstorageprovider/sharesstorageprovider.go | 5 ++--- .../http/services/owncloud/ocs/data/capabilities.go | 6 +++--- .../v2/internal/http/services/sciencemesh/sciencemesh.go | 2 +- .../cs3org/reva/v2/pkg/ocm/provider/authorizer/json/json.go | 6 +----- vendor/modules.txt | 3 ++- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 67f4a19bc8a..dc9e95ad775 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.7.0 github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 - github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f + github.com/cs3org/reva/v2 v2.16.1-0.20231108203308-830ea5043940 github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e @@ -346,3 +346,6 @@ require ( ) replace github.com/go-micro/plugins/v4/store/nats-js => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a + +// remove after the reva/edge become stable +replace github.com/cs3org/reva/v2 => github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 diff --git a/go.sum b/go.sum index 7eb6de2f7c2..65908625246 100644 --- a/go.sum +++ b/go.sum @@ -762,6 +762,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= +github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 h1:Xs789o+ZcrgQqBZ6pT2WIvgsR9lWpFQfZsh6D6d0PS8= +github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= github.com/Azure/azure-sdk-for-go v32.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-storage-blob-go v0.14.0/go.mod h1:SMqIBi+SuiQH32bvyjngEewEeXoPfKMgWlBDaYf6fck= @@ -1013,8 +1015,6 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f h1:WObbHWbihhh98V9tjjBUsIYKR3qIMDY0/9cve8KLWr4= -github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go index 207992f515b..e363aec269f 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go @@ -643,10 +643,9 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide Status: rpcStatus, }, nil } - - if dstReceivedShare.Share.Id.OpaqueId != srcReceivedShare.Share.Id.OpaqueId { + if srcReceivedShare.Share.ResourceId.SpaceId != dstReceivedShare.Share.ResourceId.SpaceId { return &provider.MoveResponse{ - Status: status.NewUnimplemented(ctx, nil, "sharesstorageprovider: can not move between shares"), + Status: status.NewInvalid(ctx, "sharesstorageprovider: can not move between shares on different storages"), }, nil } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go index 7718d2b2a07..5cb153face3 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go @@ -82,13 +82,13 @@ type CapabilitiesSearchProperties struct { // CapabilitiesSearchProperty represents the default search property type CapabilitiesSearchProperty struct { - Enabled bool `json:"enabled" xml:"enabled" mapstructure:"enabled"` + Enabled ocsBool `json:"enabled" xml:"enabled" mapstructure:"enabled"` } // CapabilitiesSearchPropertyExtended represents the extended search property type CapabilitiesSearchPropertyExtended struct { - CapabilitiesSearchProperty - Keywords []string `json:"keywords,omitempty" xml:"keywords,omitempty" mapstructure:"keywords"` + CapabilitiesSearchProperty `mapstructure:",squash"` + Keywords []string `json:"keywords,omitempty" xml:"keywords,omitempty" mapstructure:"keywords"` } // Spaces lets a service configure its advertised options related to Storage Spaces. diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/sciencemesh/sciencemesh.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/sciencemesh/sciencemesh.go index e98d49d9fe2..67b2f902a9e 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/sciencemesh/sciencemesh.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/sciencemesh/sciencemesh.go @@ -105,7 +105,7 @@ func (s *svc) routerInit() error { return err } - s.router.Post("/generate-invite", tokenHandler.Generate) + s.router.Get("/generate-invite", tokenHandler.Generate) s.router.Get("/list-invite", tokenHandler.ListInvite) s.router.Post("/accept-invite", tokenHandler.AcceptInvite) s.router.Get("/find-accepted-users", tokenHandler.FindAccepted) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/ocm/provider/authorizer/json/json.go b/vendor/github.com/cs3org/reva/v2/pkg/ocm/provider/authorizer/json/json.go index b2173c6b715..a1d11074eb1 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/ocm/provider/authorizer/json/json.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/ocm/provider/authorizer/json/json.go @@ -163,11 +163,7 @@ func (a *authorizer) IsProviderAllowed(ctx context.Context, pi *ocmprovider.Prov if hostIPs, ok := a.providerIPs.Load(ocmHost); ok { ipList = hostIPs.([]string) } else { - host, _, err := net.SplitHostPort(ocmHost) - if err != nil { - return errors.Wrap(err, "json: error looking up client IP") - } - addr, err := net.LookupIP(host) + addr, err := net.LookupIP(ocmHost) if err != nil { return errors.Wrap(err, "json: error looking up client IP") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 8c39d041215..ac8d50c8934 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -357,7 +357,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.16.1-0.20231108120331-715bd782689f +# github.com/cs3org/reva/v2 v2.16.1-0.20231108203308-830ea5043940 => github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime @@ -2272,3 +2272,4 @@ stash.kopano.io/kgol/oidc-go ## explicit; go 1.13 stash.kopano.io/kgol/rndm # github.com/go-micro/plugins/v4/store/nats-js => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a +# github.com/cs3org/reva/v2 => github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 From 193799e50653a9b4d8d94ad18bc8d7814c6302fa Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Thu, 9 Nov 2023 15:03:05 +0100 Subject: [PATCH 4/5] changed the filter name. fix types --- .../unreleased/add-file-type-filter-chip.md | 9 ++--- go.mod | 5 +-- go.sum | 4 +- services/frontend/pkg/revaconfig/config.go | 2 +- services/search/pkg/query/bleve/compiler.go | 38 ++++++++----------- .../search/pkg/query/bleve/compiler_test.go | 16 ++++---- .../sharesstorageprovider.go | 5 ++- .../owncloud/ocs/data/capabilities.go | 18 ++++----- .../http/services/sciencemesh/sciencemesh.go | 2 +- .../pkg/ocm/provider/authorizer/json/json.go | 6 ++- .../utils/decomposedfs/upload/upload.go | 2 +- vendor/modules.txt | 3 +- 12 files changed, 50 insertions(+), 60 deletions(-) diff --git a/changelog/unreleased/add-file-type-filter-chip.md b/changelog/unreleased/add-file-type-filter-chip.md index 092a37e318a..32da278164e 100644 --- a/changelog/unreleased/add-file-type-filter-chip.md +++ b/changelog/unreleased/add-file-type-filter-chip.md @@ -1,7 +1,7 @@ -Enhancement: Add search mimetype filter +Enhancement: Add search MediaType filter -Add filter MimeType filter shortcuts to search for specific document types. -For example, a search query MimeType:documents will search for files with the following mimetypes: +Add filter MediaType filter shortcuts to search for specific document types. +For example, a search query mediatype:documents will search for files with the following mimetypes: application/msword MimeType:application/vnd.openxmlformats-officedocument.wordprocessingml.document @@ -43,8 +43,6 @@ application/vnd.apple.pages application/vnd.ms-excel application/vnd.oasis.opendocument.spreadsheet text/csv -application/vnd.openxmlformats-officedocument.presentationml.presentation -application/vnd.oasis.opendocument.presentation application/vnd.openxmlformats-officedocument.spreadsheetml.sheet application/vnd.oasis.opendocument.spreadsheet application/vnd.apple.numbers @@ -55,7 +53,6 @@ application/vnd.ms-powerpoint application/vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.oasis.opendocument.presentation application/vnd.apple.keynote -application/vnd.ms-excel ## PDF diff --git a/go.mod b/go.mod index dc9e95ad775..74c1350de3e 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.7.0 github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 - github.com/cs3org/reva/v2 v2.16.1-0.20231108203308-830ea5043940 + github.com/cs3org/reva/v2 v2.16.1-0.20231110061744-953e57a6a95c github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e @@ -346,6 +346,3 @@ require ( ) replace github.com/go-micro/plugins/v4/store/nats-js => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a - -// remove after the reva/edge become stable -replace github.com/cs3org/reva/v2 => github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 diff --git a/go.sum b/go.sum index 65908625246..14d62add7a3 100644 --- a/go.sum +++ b/go.sum @@ -762,8 +762,6 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= -github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 h1:Xs789o+ZcrgQqBZ6pT2WIvgsR9lWpFQfZsh6D6d0PS8= -github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= github.com/Azure/azure-sdk-for-go v32.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-storage-blob-go v0.14.0/go.mod h1:SMqIBi+SuiQH32bvyjngEewEeXoPfKMgWlBDaYf6fck= @@ -1015,6 +1013,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= +github.com/cs3org/reva/v2 v2.16.1-0.20231110061744-953e57a6a95c h1:sxTOKm1ChsykAm8ITLHXNSic9RTUfpAq6Ujj94/irXQ= +github.com/cs3org/reva/v2 v2.16.1-0.20231110061744-953e57a6a95c/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index 6dad0372b29..cef10f4abb6 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -302,7 +302,7 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string "size": map[string]interface{}{ "enabled": false, }, - "mimetype": map[string]interface{}{ + "mediatype": map[string]interface{}{ "keywords": []string{"file", "folder", "document", "spreadsheet", "presentation", "pdf", "image", "video", "audio", "archive"}, "enabled": true, }, diff --git a/services/search/pkg/query/bleve/compiler.go b/services/search/pkg/query/bleve/compiler.go index 6b64844d344..0e5f82786fb 100644 --- a/services/search/pkg/query/bleve/compiler.go +++ b/services/search/pkg/query/bleve/compiler.go @@ -6,24 +6,23 @@ import ( "github.com/blevesearch/bleve/v2" bleveQuery "github.com/blevesearch/bleve/v2/search/query" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" "github.com/owncloud/ocis/v2/services/search/pkg/query/kql" ) var _fields = map[string]string{ - "rootid": "RootID", - "path": "Path", - "id": "ID", - "name": "Name", - "size": "Size", - "mtime": "Mtime", - "mimetype": "MimeType", - "type": "Type", - "tag": "Tags", - "tags": "Tags", - "content": "Content", - "hidden": "Hidden", + "rootid": "RootID", + "path": "Path", + "id": "ID", + "name": "Name", + "size": "Size", + "mtime": "Mtime", + "mediatype": "MimeType", + "type": "Type", + "tag": "Tags", + "tags": "Tags", + "content": "Content", + "hidden": "Hidden", } // The following quoted string enumerates the characters which may be escaped: "+-=&|> github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 +# github.com/cs3org/reva/v2 v2.16.1-0.20231110061744-953e57a6a95c ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime @@ -2272,4 +2272,3 @@ stash.kopano.io/kgol/oidc-go ## explicit; go 1.13 stash.kopano.io/kgol/rndm # github.com/go-micro/plugins/v4/store/nats-js => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a -# github.com/cs3org/reva/v2 => github.com/2403905/reva/v2 v2.0.0-20231109082047-f3a039cbc1e4 From b96ecb8ea9a4e57d071235daaa0c87ae11c6a1fa Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Mon, 13 Nov 2023 16:19:30 +0100 Subject: [PATCH 5/5] rework mapBinary --- services/search/pkg/query/bleve/compiler.go | 61 ++++++++++----------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/services/search/pkg/query/bleve/compiler.go b/services/search/pkg/query/bleve/compiler.go index 0e5f82786fb..7464211a10e 100644 --- a/services/search/pkg/query/bleve/compiler.go +++ b/services/search/pkg/query/bleve/compiler.go @@ -220,47 +220,44 @@ func nextNode(offset int, nodes []ast.Node) (bleveQuery.Query, int, error) { } func mapBinary(operator *ast.OperatorNode, ln, rn bleveQuery.Query, leftIsGroup bool) bleveQuery.Query { - if operator.Value == kql.BoolAND { - if left, ok := ln.(*bleveQuery.ConjunctionQuery); ok { - left.AddQuery(rn) - return left - } - if left, ok := ln.(*bleveQuery.DisjunctionQuery); ok && !leftIsGroup { - last := left.Disjuncts[len(left.Disjuncts)-1] - rn = bleveQuery.NewConjunctionQuery([]bleveQuery.Query{ - last, - rn, - }) - dj := bleveQuery.NewDisjunctionQuery(left.Disjuncts[:len(left.Disjuncts)-1]) - dj.AddQuery(rn) - return dj - } - return bleveQuery.NewConjunctionQuery([]bleveQuery.Query{ - ln, - rn, - }) - } if operator.Value == kql.BoolOR { - if left, ok := ln.(*bleveQuery.DisjunctionQuery); ok { - // if both are DisjunctionQuery then merge - if right, ok := rn.(*bleveQuery.DisjunctionQuery); ok { + right, ok := rn.(*bleveQuery.DisjunctionQuery) + switch left := ln.(type) { + case *bleveQuery.DisjunctionQuery: + if ok { left.AddQuery(right.Disjuncts...) - return left + } else { + left.AddQuery(rn) } - left.AddQuery(rn) return left - } - if _, ok := ln.(*bleveQuery.ConjunctionQuery); !ok { - if right, ok := rn.(*bleveQuery.DisjunctionQuery); ok { + case *bleveQuery.ConjunctionQuery: + return bleveQuery.NewDisjunctionQuery([]bleveQuery.Query{ln, rn}) + default: + if ok { left := bleveQuery.NewDisjunctionQuery([]bleveQuery.Query{ln}) left.AddQuery(right.Disjuncts...) return left } + return bleveQuery.NewDisjunctionQuery([]bleveQuery.Query{ln, rn}) + } + } + if operator.Value == kql.BoolAND { + switch left := ln.(type) { + case *bleveQuery.ConjunctionQuery: + left.AddQuery(rn) + return left + case *bleveQuery.DisjunctionQuery: + if !leftIsGroup { + last := left.Disjuncts[len(left.Disjuncts)-1] + rn = bleveQuery.NewConjunctionQuery([]bleveQuery.Query{ + last, + rn, + }) + dj := bleveQuery.NewDisjunctionQuery(left.Disjuncts[:len(left.Disjuncts)-1]) + dj.AddQuery(rn) + return dj + } } - return bleveQuery.NewDisjunctionQuery([]bleveQuery.Query{ - ln, - rn, - }) } return bleveQuery.NewConjunctionQuery([]bleveQuery.Query{ ln,