plone.restapi icon indicating copy to clipboard operation
plone.restapi copied to clipboard

Support 'not' queries with @search endpoint.

Open maethu opened this issue 1 year ago • 6 comments

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

maethu avatar Feb 20 '24 20:02 maethu

@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!

mister-roboto avatar Feb 20 '24 20:02 mister-roboto

Deploy Preview for plone-restapi canceled.

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

netlify[bot] avatar Feb 20 '24 20:02 netlify[bot]

@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 avatar Feb 20 '24 20:02 maethu

@jenkins-plone-org please run jobs

maethu avatar Feb 20 '24 20:02 maethu

@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.

davisagli avatar Feb 20 '24 20:02 davisagli