Allow filtering the search results to the users home storage#17941
Allow filtering the search results to the users home storage#17941
Conversation
|
Full search example <?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:basicsearch>
<d:select>
<d:prop>
<d:getcontenttype/>
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/admin</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:and>
<d:like>
<d:prop>
<d:getcontenttype/>
</d:prop>
<d:literal>image/%</d:literal>
</d:like>
<d:eq>
<d:prop>
<oc:owner-id/>
</d:prop>
<d:literal>admin</d:literal>
</d:eq>
</d:and>
</d:where>
<d:orderby/>
</d:basicsearch>
</d:searchrequest> |
This comment has been minimized.
This comment has been minimized.
| $value = $operator->arguments[1]->value; | ||
|
|
||
| // to remove the comparison from the query, we replace it with an empty AND | ||
| $operator = new Operator(Operator::OPERATION_AND); |
There was a problem hiding this comment.
I'm not a fan. Could you consider to keep it? Sure we need owner as property at mapPropertyNameToColumn and still need to move $comparison->getField() === 'owner' before validateComparison. I think this is less hacky ;)
There was a problem hiding this comment.
My original plan was something like that but you'll still need to remove the comparison from the query since there is no column related to the owner field, this way the logic is confirmed to a single place
There was a problem hiding this comment.
Fine by me 👍 I see your point keeping the logic together. searchComparisonToDBExpr is more or less a generic method and adding "do nothing if owner field" there is bad. The fake operator is also bad. Guess it does not matter which bad we pick ;)
rullzer
left a comment
There was a problem hiding this comment.
Seems towork. But please have a look at the comments
7db7fb6 to
5dcdb24
Compare
|
@icewind1991 rebased. |
This is done by adding a
```xml
<d:eq>
<d:prop>
<oc:owner-id/>
</d:prop>
<d:literal>$userId</d:literal>
</d:eq>
```
clause to the search query.
Searching by `owner-id` can only be done with the current user id
and the comparison can not be inside a `<d:not>` or `<d:or>` statement
Signed-off-by: Robin Appelman <robin@icewind.nl>
5dcdb24 to
c62637d
Compare
|
Feature freeze is here, we need to get this in! |
|
Also, applying limit to a search with an ownerid filter doesn't respect the limit. |
|
TEsts failures: |
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
I can't reproduce this, "non owner" files are never searched and thus never part of the sorting or limit |
I don't know, I added a limit and it was returning less entries than the said limit |
<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns">
<d:basicsearch>
<d:select>
<d:prop>
<d:getlastmodified />
<d:getetag />
<d:getcontenttype />
<oc:fileid />
<d:getcontentlength />
<nc:has-preview />
<oc:favorite />
<d:resourcetype />
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/admin</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:and>
<d:or>
<d:eq>
<d:prop>
<d:getcontenttype />
</d:prop>
<d:literal>image/jpeg</d:literal>
</d:eq>
<d:eq>
<d:prop>
<d:getcontenttype />
</d:prop>
<d:literal>video/mp4</d:literal>
</d:eq>
<d:eq>
<d:prop>
<d:getcontenttype />
</d:prop>
<d:literal>video/quicktime</d:literal>
</d:eq>
</d:or>
<!-- removing this eq solves the limit issue -->
<d:eq>
<d:prop>
<oc:owner-id />
</d:prop>
<d:literal>admin</d:literal>
</d:eq>
</d:and>
</d:where>
<d:orderby>
<d:order>
<d:prop>
<d:getlastmodified />
</d:prop>
<d:descending />
</d:order>
</d:orderby>
<d:limit>
<d:nresults>5</d:nresults>
</d:limit>
</d:basicsearch>
</d:searchrequest> |
|
stupid question but just making sure, do you have more then 2 matching files in your home storage? |
yes removing the limite gives me 30 results ;) |
|
Can you step trough the code with a debugger from |
|
This has to come from the |
|
it might be filtering out results from outside |
|
Looks like you're right! server/lib/private/Files/Node/Folder.php Lines 251 to 258 in c62637d |
|
Lets merge this for now and open an issue for the remaining fix during the beta |









This is done by adding a
clause to the search query.
Searching by
owner-idcan only be done with the current user idand the comparison can not be inside a
<d:not>or<d:or>statementSigned-off-by: Robin Appelman robin@icewind.nl