Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Search filter for locations #6713

Merged
merged 4 commits into from
Jul 12, 2023
Merged

Conversation

2403905
Copy link
Contributor

@2403905 2403905 commented Jul 4, 2023

Description

Related Issue

  • Enhancement: [ocis] Provide Search filter for locations OCIS-3705

Motivation and Context

Acceptance Criteria

  • provide possibility for the client to restrict the search to the current folder via api (recursive)
  • scope needed for "current folder" (default is to search all available spaces) - part of the oc-pattern:"scope:<uuid>/Test"
  • search service only retruns results in the given scope
  • API call is documented in dev docs

How Has This Been Tested?

  • test environment: Local
  • test case 1:
    1.1 Login as admin; go to the Personal; create the file 'testfile.txt'; create the folder 'nfolder' and create inside the file 'newfile.txt'.
    1.2 Call the API by name and location <oc:pattern>file scope:storage-users-1$some-admin-user-id-0000-000000000000!some-admin-user-id-0000-000000000000/nfolder</oc:pattern> have to return only the 'newfile.txt' as a search result.
    Request:
curl 'https://localhost:9200/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000' \
  -X 'REPORT' \
  --data-raw $'<?xml version="1.0"?>\n<oc:search-files  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">\n  <d:prop>\n    <oc:permissions />\n    <oc:favorite />\n    <oc:fileid />\n    <oc:file-parent />\n    <oc:name />\n    <oc:owner-id />\n    <oc:owner-display-name />\n    <oc:shareid />\n    <oc:shareroot />\n    <oc:share-types />\n    <oc:privatelink />\n    <d:getcontentlength />\n    <oc:size />\n    <d:getlastmodified />\n    <d:getetag />\n    <d:getcontenttype />\n    <d:resourcetype />\n    <oc:downloadURL />\n    <oc:tags />\n  </d:prop>\n  <oc:search>\n    <oc:pattern>file scope:storage-users-1$some-admin-user-id-0000-000000000000/nfolder</oc:pattern>\n    <oc:limit>8</oc:limit>\n  </oc:search>\n</oc:search-files>' \
  -ik \
  -uadmin:admin

Response:

HTTP/1.1 207 Multi-Status
Cache-Control: no-cache, no-store, max-age=0, must-revalidate, value
Content-Length: 916
Content-Range: rows 0-0/7
Content-Security-Policy: frame-ancestors 'none'
Content-Type: application/xml; charset=utf-8
Date: Fri, 07 Jul 2023 09:24:15 GMT
Dav: 1, 3, extended-mkcol
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified: Fri, 07 Jul 2023 09:24:15 GMT
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Webdav-Version: 3.1.0-next.2+dev

<d:multistatus xmlns:s="http://sabredav.org/ns" xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:response><d:href>/remote.php/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000/newfile.txt</d:href><d:propstat><d:prop><oc:fileid>storage-users-1$some-admin-user-id-0000-000000000000!6531b70d-fe7d-45d2-85ed-c9f70bd553e8</oc:fileid><oc:file-parent>storage-users-1$some-admin-user-id-0000-000000000000!80fcf9f6-2ed2-40cc-b12a-db170576d3c4</oc:file-parent><oc:name>newfile.txt</oc:name><d:getlastmodified>2023-06-27T09:38:14Z</d:getlastmodified><d:getcontenttype>text/plain</d:getcontenttype><oc:permissions>RDNVW</oc:permissions><oc:highlights></oc:highlights><oc:tags></oc:tags><d:getetag></d:getetag><d:resourcetype></d:resourcetype><d:getcontentlength>3</d:getcontentlength><oc:score>0.19501826167106628</oc:score></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>%
  1. Search in the Shares
    2.1 Admin shared the folder with Einstein and this folder contains a subfolder.
    The search request will be:
    curl 'https://localhost:9200/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!storage-users-1:some-admin-user-id-0000-000000000000:7abb7cb0-8dc8-4011-b485-3e5b816a136b/' \ -X 'REPORT' \ --data-raw $'<?xml version="1.0"?>\n<oc:search-files xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">\n <d:prop>\n <oc:permissions />\n <oc:favorite />\n <oc:fileid />\n <oc:file-parent />\n <oc:name />\n <oc:owner-id />\n <oc:owner-display-name />\n <oc:shareid />\n <oc:shareroot />\n <oc:share-types />\n <oc:privatelink />\n <d:getcontentlength />\n <oc:size />\n <d:getlastmodified />\n <d:getetag />\n <d:getcontenttype />\n <d:resourcetype />\n <oc:downloadURL />\n <oc:tags />\n </d:prop>\n <oc:search>\n <oc:pattern>file scope:a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!storage-users-1:some-admin-user-id-0000-000000000000:7abb7cb0-8dc8-4011-b485-3e5b816a136b/subfolder</oc:pattern>\n <oc:limit>8</oc:limit>\n </oc:search>\n</oc:search-files>' \ -ik \ -ueinstein:relativity

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

services/search/pkg/search/service.go Outdated Show resolved Hide resolved
services/search/pkg/search/search.go Show resolved Hide resolved
services/search/pkg/search/search.go Outdated Show resolved Hide resolved
services/search/pkg/search/service.go Outdated Show resolved Hide resolved
services/search/pkg/search/service.go Outdated Show resolved Hide resolved
services/search/pkg/search/service_test.go Show resolved Hide resolved
@2403905 2403905 force-pushed the OCIS-3705 branch 2 times, most recently from 78066a4 to 2f50270 Compare July 6, 2023 09:47
@2403905 2403905 requested a review from aduffeck July 6, 2023 09:47
@2403905 2403905 force-pushed the OCIS-3705 branch 6 times, most recently from 0c99d04 to a569a49 Compare July 12, 2023 12:09
Copy link
Contributor

@aduffeck aduffeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm besides the problem with the "total matches" fix.

services/search/pkg/engine/bleve.go Outdated Show resolved Hide resolved
@2403905 2403905 force-pushed the OCIS-3705 branch 2 times, most recently from bff28e0 to 5304142 Compare July 12, 2023 13:49
@2403905 2403905 requested a review from aduffeck July 12, 2023 14:02
@sonarcloud
Copy link

sonarcloud bot commented Jul 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.2% 92.2% Coverage
0.0% 0.0% Duplication

@2403905 2403905 merged commit aad05c9 into owncloud:master Jul 12, 2023
2 checks passed
ownclouders pushed a commit that referenced this pull request Jul 12, 2023
Provide Search filter for locations
ownclouders pushed a commit that referenced this pull request Jul 12, 2023
Provide Search filter for locations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants