Comments (8)
@lukasgraf thanks for the writeup! I tried to wrap my head around this issue as well and haven't reached a final conclusion yet.
You can ignore searching.rst. This was a very early draft before we even looked at existing solutions. I will try to find some time to do some more research. Though, this seems to be a topic that most API architects seem to avoid talking about. ;)
Just a remark regarding POST vs. GET. It seems that some people argue that you actually create a search with a query and therefore a POST request can also be correct in REST terms. Though, you are of course correct with the other disadvantages (caching, no URL, etc.).
from plone.restapi.
Great job @lukasgraf !
I love your ideas, in some projects we are using JWT (jwt.io) to have the search query on a parameter as they can be complex. If we wanna support complex queries , the parameters get complex and jwt allows to define a JSON format.
I would support only GET verb.
It may be an option to have to endpoints ? one for text search and one for complex search ?
from plone.restapi.
Just a remark regarding POST vs. GET. It seems that some people argue that you actually create a search with a query and therefore a POST request can also be correct in REST terms. Though, you are of course correct with the other disadvantages (caching, no URL, etc.).
Yes, I've also seen POST
being used. I created a separate issue #46 for discussing a potential concept to maybe address some race conditions with batching - that would require a POST
anyway.
If we wanna support complex queries , the parameters get complex and jwt allows to define a JSON format.
Yes, for any non-trivial query I don't really see anything besides JSON as an option any more. We really don't want to write our own query DSL.
I would support only GET verb.
We (4tw) also have a strong tendency towards that, if we can make it work.
I'd argue that then means that 3) (GET
+ JSON in query string) emerges as a promising option.
It may be an option to have to endpoints ? one for text search and one for complex search ?
Yes, we also considered that. For now I'd like to focus on an implementation that can gracefully handle complex queries, because that's the hard case, but I could very well see a limited simple_search
endpoint with a simplified syntax and reduced functionality.
from plone.restapi.
I'd love to have a simple JSON-payload rather than having to build a compliacated GET-querystring.
Because GET + payload is a problem I'm therefore in favor of using payloads with POST-requests (nr. 4.)
from plone.restapi.
For 3) it would be about as complicated as this 😜
query_json = quote_plus(json.dumps(query))
requests.get(url, params={'q': json_query})
Or with curl
:
curl -G -H 'Accept: application/json' $URL --data-urlencode 'q={"SearchableText": "foobar"}'
Or with httpie
:
http -j GET $URL q=='{"SearchableText": "foobar"}'
Maybe offering both is the way to go? As long as the serialization format is JSON for both, implementation and documentation overhead should be minimal.
from plone.restapi.
That's for me ok as well. I think we should just implement a first version; it can be extended later..
from plone.restapi.
Updated:
The use of JSON only allows to retain some typing information, but not all (datetime
isn't JSON serializable).
This significantly diminishes the advantage of the use of JSON as the query serialization format, because we still need to have a mechanism in place to reconstruct typing information based on knowledge about the index that's being queried.
Under these circumstances I really don't see a point in also offering POST
anymore. While on the implementation side it's trivial to also support POST
, it still needs to be tested and documented. Also, offering two ways to do the same thing goes against the Zen of Python There should be one-- and preferably only one --obvious way to do it.
, and might confuse our users.
For this reason, I think GET
with query string and optional Zope type hints is the way to go. I'll update my search PR (#48) accordingly in the next few days and propose a GET
only implementation.
from plone.restapi.
A first version implementing GET
with query string has been merged with #48
from plone.restapi.
Related Issues (20)
- KeyError: 'portal' in tests with Python 3.12.1 HOT 10
- Translate validation error messages
- IBlocks SearchableText indexer bypasses plone.textindexer behavior HOT 2
- relatedItems field returns None in the serializer if the related item is deleted HOT 1
- Site Administrator cannot add user to group
- Add remote_url(getRemoteUrl) to link content-types in navigation HOT 4
- Include release notes in Plone 6 Documentation
- Authentication error messages from PAS Plugins aren't returned by the restapi HOT 1
- restapi double parameter is broking code. HOT 8
- In content that uses the plone.blocks behavior, it is not possible to add fields to SearchableText with "plone.app.dexterity.textindexer" HOT 6
- Community Forum App Icon Not Filling Correctly. HOT 1
- Add plone.app.discussion control panel
- Types control panel does not allow to enable/disable discussion for a content type
- Implement SummaryDiscussionListingTemplate to fix Discussion url in listings HOT 1
- Documentation of event content type does not return a timezone
- NoneType' object has no attribute 'getProperty': when searching users HOT 1
- @querystring shouldn't list userids
- Test with Plone 6.1 HOT 1
- Require plone.app.iterate on test extras
- Require plone.app.upgrade in test extras
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plone.restapi.