plone / plone.restapi

RESTful API for Plone.
http://plonerestapi.readthedocs.org/
84 stars 73 forks source link

Support 'not' queries with @search endpoint. #1752

Open maethu opened 4 months ago

maethu commented 4 months ago

This PR adds support to exclude certain items from the result set using not for DateIndex, FieldIndex and KeywordIndex.

Example request:

GET /Plone/@search?Subject.not=important&path.query=%2FPlone&path.depth=-1 HTTP/1.1

Returns all items not having the subject "important".

Only works with Plone 6

mister-roboto commented 4 months ago

@maethu thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

netlify[bot] commented 4 months ago

Deploy Preview for plone-restapi canceled.

Name Link
Latest commit 7c26758d1fae5151dcb10ac2f83f6834ed48d722
Latest deploy log https://app.netlify.com/sites/plone-restapi/deploys/65d50902a57a6d00080c4ec1
maethu commented 4 months ago

@maethu This is already supported by the @querystring-search endpoint using the isNot and none operations (see plone/plone.app.querystring#110). Is there a reason it's needed for the @search endpoint as well?

Thanks very much, @davisagli, I'm aware of that. On my project, I use the @search endpoint for my search form because the form state management requires much less code via @search endpoint than it does via @querystring-search. I also don't have to update a deeply nested state. On top, it's a way more readable URL, mostly because it's shorter.

No hard feelings if it does not make sense in plone.restapi. I can keep my patch in my project. I just thought maybe it would make sense to give this upstream.

maethu commented 4 months ago

@jenkins-plone-org please run jobs

davisagli commented 4 months ago

@maethu Thanks, I'll take another look and also ask @tisto for his opinion. If we do decide to add it, it will need documentation.