Skip to content

Commit

Permalink
changed the filter name. fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Nov 13, 2023
1 parent 6e83e1e commit 193799e
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 60 deletions.
9 changes: 3 additions & 6 deletions changelog/unreleased/add-file-type-filter-chip.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion services/frontend/pkg/revaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
38 changes: 15 additions & 23 deletions services/search/pkg/query/bleve/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "+-=&|><!(){}[]^\"~*?:\\/ "
Expand Down Expand Up @@ -311,22 +310,16 @@ func mimeType(k, v string) (bleveQuery.Query, bool) {
"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 "presentation":
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",
"application/vnd.ms-powerpoint",
"application/vnd.apple.keynote",
)), true
case "pdf":
return bleveQuery.NewQueryStringQuery(k + ":application/pdf"), false
Expand All @@ -341,8 +334,7 @@ func mimeType(k, v string) (bleveQuery.Query, bool) {
"application/zip",
"application/x-tar",
"application/x-gzip",
"application/x-7",
"z-compressed",
"application/x-7z-compressed",
"application/x-rar-compressed",
"application/x-bzip2",
"application/x-bzip",
Expand Down
16 changes: 8 additions & 8 deletions services/search/pkg/query/bleve/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func Test_compile(t *testing.T) {
name: `MimeType:document`,
args: &ast.Ast{
Nodes: []ast.Node{
&ast.StringNode{Key: "mimetype", Value: "document"},
&ast.StringNode{Key: "mediatype", Value: "document"},
},
},
want: query.NewDisjunctionQuery([]query.Query{
Expand All @@ -408,7 +408,7 @@ func Test_compile(t *testing.T) {
name: `MimeType:document AND *tdd*`,
args: &ast.Ast{
Nodes: []ast.Node{
&ast.StringNode{Key: "mimetype", Value: "document"},
&ast.StringNode{Key: "mediatype", Value: "document"},
&ast.OperatorNode{Value: "AND"},
&ast.StringNode{Key: "name", Value: "*tdd*"},
},
Expand All @@ -431,9 +431,9 @@ func Test_compile(t *testing.T) {
name: `MimeType:document OR MimeType:pdf AND *tdd*`,
args: &ast.Ast{
Nodes: []ast.Node{
&ast.StringNode{Key: "mimetype", Value: "document"},
&ast.StringNode{Key: "mediatype", Value: "document"},
&ast.OperatorNode{Value: "OR"},
&ast.StringNode{Key: "mimetype", Value: "pdf"},
&ast.StringNode{Key: "mediatype", Value: "pdf"},
&ast.OperatorNode{Value: "AND"},
&ast.StringNode{Key: "name", Value: "*tdd*"},
},
Expand All @@ -458,9 +458,9 @@ func Test_compile(t *testing.T) {
args: &ast.Ast{
Nodes: []ast.Node{
&ast.GroupNode{Nodes: []ast.Node{
&ast.StringNode{Key: "mimetype", Value: "document"},
&ast.StringNode{Key: "mediatype", Value: "document"},
&ast.OperatorNode{Value: "OR"},
&ast.StringNode{Key: "mimetype", Value: "pdf"},
&ast.StringNode{Key: "mediatype", Value: "pdf"},
}},
&ast.OperatorNode{Value: "AND"},
&ast.StringNode{Key: "name", Value: "*tdd*"},
Expand All @@ -486,9 +486,9 @@ func Test_compile(t *testing.T) {
args: &ast.Ast{
Nodes: []ast.Node{
&ast.GroupNode{Nodes: []ast.Node{
&ast.StringNode{Key: "mimetype", Value: "pdf"},
&ast.StringNode{Key: "mediatype", Value: "pdf"},
&ast.OperatorNode{Value: "OR"},
&ast.StringNode{Key: "mimetype", Value: "document"},
&ast.StringNode{Key: "mediatype", Value: "document"},
}},
&ast.OperatorNode{Value: "AND"},
&ast.StringNode{Key: "name", Value: "*tdd*"},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.20231108203308-830ea5043940 => 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
Expand Down Expand Up @@ -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

0 comments on commit 193799e

Please sign in to comment.