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

feat(search): allows to search by parent ID #46527

Closed
wants to merge 1 commit into from

Conversation

Altahrim
Copy link
Collaborator

Summary

Allows to filter on parent ID in a SEARCH request

<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
  <d:basicsearch>
    <d:select>
      <d:prop>
        <d:displayname/>
        <d:getcontentlength/>
        <d:getcontenttype/>
      </d:prop>
    </d:select>
    <d:from>
      <d:scope>
        <d:href>/files/admin/Media</d:href> <!-- Filter from path -->
        <d:depth>1</d:depth>
      </d:scope>
    </d:from>
    <d:where>
      <d:eq>
        <d:prop>
          <d:parentid/>  <!-- Filter on parentid -->
        </d:prop>
        <d:literal>3</d:literal> <!-- Filter value (oc:fileid of parent directory) -->
      </d:eq>
    </d:where>
    <d:limit>
      <d:nresults>2</d:nresults>
      <ns:firstresult>0</ns:firstresult>
    </d:limit>
  </d:basicsearch>
</d:searchrequest>

Checklist

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
@Altahrim Altahrim added the 2. developing Work in progress label Jul 15, 2024
@Altahrim Altahrim added this to the Nextcloud 30 milestone Jul 15, 2024
@Altahrim Altahrim self-assigned this Jul 15, 2024
@Altahrim Altahrim added the php Pull requests that update Php code label Jul 15, 2024
@icewind1991
Copy link
Member

The change looks fine, but is there any reason for not just using the parent folder as scope and searching with depth 1?

@Altahrim
Copy link
Collaborator Author

Good question! It doesn't work because we need to have a search but then I forgot the reason…
It could be a better choice to allow an empty search

@Altahrim
Copy link
Collaborator Author

Another reason: according to my tests depth isn't respected…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress php Pull requests that update Php code
Projects
Status: ☑️ Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants