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

fix search highlights for REPORT request #38787

Merged
merged 3 commits into from
Jun 14, 2021
Merged

fix search highlights for REPORT request #38787

merged 3 commits into from
Jun 14, 2021

Conversation

micbar
Copy link
Contributor

@micbar micbar commented May 27, 2021

Description

File Search should be done in the future via WebDAV REPORT requests.

ownCloud web is using it.

In combination with the Full Text Search app, we have more properties to return.

<oc:search-highlights /> => returns am html formatted excerpt of the file content which is highlighting the matching words.

<oc:search-score /> => returns a float number score value

Usage

Request

curl --location --request REPORT 'http://cloud.local/remote.php/dav/files/admin/' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Content-Type: text/plain' \
--data-raw '<?xml version="1.0" encoding="UTF-8"?>
<oc:search-files
    xmlns:a="DAV:"
    xmlns:oc="http://owncloud.org/ns">
    <a:prop>
        <a:getcontentlength />
        <a:getcontenttype />
        <a:getetag />
        <a:getlastmodified />
        <a:lockdiscovery />
        <a:resourcetype />
        <oc:comments-unread />
        <oc:favorites />
        <oc:fileid />
        <oc:owner-display-name />
        <oc:permissions />
        <oc:share-types />
        <oc:size />
        <oc:tags />
        <oc:search-highlights />
        <oc:search-score />
    </a:prop>
    <oc:search>
        <oc:pattern>wel</oc:pattern>
    </oc:search>
</oc:search-files>'

Response Body

<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
    <d:response>
        <d:href>/remote.php/dav/files/admin/welcome.txt</d:href>
        <d:propstat>
            <d:prop>
                <d:getcontentlength>167</d:getcontentlength>
                <d:getcontenttype>text/plain</d:getcontenttype>
                <d:getetag>&quot;7e33c954889e86d9a710130a04608559&quot;</d:getetag>
                <d:getlastmodified>Tue, 18 May 2021 18:48:27 GMT</d:getlastmodified>
                <d:lockdiscovery/>
                <d:resourcetype/>
                <oc:comments-unread>0</oc:comments-unread>
                <oc:fileid>4</oc:fileid>
                <oc:owner-display-name>admin</oc:owner-display-name>
                <oc:permissions>RDNVW</oc:permissions>
                <oc:share-types/>
                <oc:size>167</oc:size>
                <oc:tags/>
                <oc:search-highlights>&lt;em&gt;Welcome&lt;/em&gt; to your ownCloud account!&lt;br/&gt;&lt;br/&gt;This is just an example file for developers and git users. &lt;br/&gt;The packaged</oc:search-highlights>
                <oc:search-score>3.4743</oc:search-score>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
        <d:propstat>
            <d:prop>
                <oc:favorites/>
            </d:prop>
            <d:status>HTTP/1.1 404 Not Found</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/remote.php/dav/files/admin/New%20folder/New%20text%20file.txt</d:href>
        <d:propstat>
            <d:prop>
                <d:getcontentlength>13</d:getcontentlength>
                <d:getcontenttype>text/plain</d:getcontenttype>
                <d:getetag>&quot;7d0e539bb33ab2892a806940b2d4172d&quot;</d:getetag>
                <d:getlastmodified>Thu, 27 May 2021 11:14:11 GMT</d:getlastmodified>
                <d:lockdiscovery/>
                <d:resourcetype/>
                <oc:comments-unread>0</oc:comments-unread>
                <oc:fileid>116</oc:fileid>
                <oc:owner-display-name>admin</oc:owner-display-name>
                <oc:permissions>RDNVW</oc:permissions>
                <oc:share-types/>
                <oc:size>13</oc:size>
                <oc:tags/>
                <oc:search-highlights>&lt;em&gt;Welcome&lt;/em&gt;&lt;br/&gt;&lt;br/&gt;&lt;em&gt;well&lt;/em&gt;</oc:search-highlights>
                <oc:search-score>3.0715303</oc:search-score>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
        <d:propstat>
            <d:prop>
                <oc:favorites/>
            </d:prop>
            <d:status>HTTP/1.1 404 Not Found</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

Motivation and Context

Make Full Text Search Features available for ownCloud Web

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • 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:
  • Changelog item, see TEMPLATE

@update-docs
Copy link

update-docs bot commented May 27, 2021

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@micbar micbar requested review from kulmann and butonic May 27, 2021 13:46
@micbar
Copy link
Contributor Author

micbar commented May 27, 2021

@kulmann as discussed, encoding of the "highlights" content is still a challenge.

@butonic Solution feels still hacky 😓 Changing the DAV app for logic from the Full Text Search app doesn't feel right.

@micbar micbar force-pushed the fix-search-hl branch 3 times, most recently from dcc0823 to d083cf0 Compare May 28, 2021 12:56
@micbar micbar marked this pull request as ready for review May 29, 2021 20:49
@micbar micbar self-assigned this Jun 8, 2021
@micbar
Copy link
Contributor Author

micbar commented Jun 8, 2021

@kulmann @butonic ready for review.

@kulmann we need to find out if this is sufficient now. The release time Frame for 10.8.0 is closing down.
Can we plan a small POC in web?

@micbar micbar force-pushed the fix-search-hl branch 3 times, most recently from 812da12 to 4509c1b Compare June 14, 2021 07:30
Copy link
Contributor

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

Cool, works like a charm 🥇 tried it out locally with the search in ownCloud Web. Results can be rendered to proper html. I was a bit surprised by the amount of linebreaks in the content of the highlights, but those are already present in the raw content, so nothing we should worry about here. Will need some changes in Web, but the encoding works well. Good to merge IMO 👍

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@micbar
Copy link
Contributor Author

micbar commented Jun 14, 2021

@phil-davis Coverage reporting works now.

@micbar micbar requested a review from phil-davis June 14, 2021 14:19
@micbar micbar merged commit f4b8fc7 into master Jun 14, 2021
@delete-merged-branch delete-merged-branch bot deleted the fix-search-hl branch June 14, 2021 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants