-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
0.8.0 draft - Part 1 #1
Conversation
@kishorenc See above |
Great review - agree with most of those suggestions and I have gone ahead and fixed them on this branch: https://github.com/wreally/typesense/tree/0.8-api-changes You can test via the docker image The issue with the CORS header is also fixed in the above image.
I don't think this is an issue. For e.g. see Github's search API which uses colon and this Stackoverflow answer.
I will add this to the documentation once we freeze on the API spec, along with the API end-point changes.
As an end-user of APIs that used to return big, raw JSON in the past, I hated that. Not all languages have a nice streaming JSON parser. Without that, you need to buffer the response in memory and parse it. JSON line is an elegant substitute as an export format. It's a cross between CSV and pure JSON. |
Great! I'm running into some other CORS issue now. I'll investigate further and reply in typesense/typesense#7.
The main reason I brought it up was because Swagger Editor was automatically URL-encoding the parameters. Let me see if there's a way to disable that.
👍 |
That's not a problem. The HTTP server automatically decodes the value. I just verified it by sending Similarly, a space in the "q" (query) field is also handled. For e.g.
Notice the space in the query |
This version aims to make the API endpoints and specifically the request/response formats more consistent with each other.
Goals:
Here's a summary of the changes:
API Routes:
The visual diff of api-routes.png in the PR below summarizes the API endpoint changes well.
Create a new sub-resource called
documents
undercollections
and update the end-points correspondingly:/collections/{collectionName}
we'd now post to/collections/{collectionName}/documents
. Currently aPOST
to/collections/{collectionName}
could mean that we're updating the collection definition itself, which is not the case./collections/{collectionName}/search
becomes/collections/{collectionName}/documents/search
since we're technically searching the documents within a collection rather than the collection (schema) itself. This removes any confusion./collections/{collectionName}/export
becomes/collections/{collectionName}/documents/export
. Same as above. We're exporting the documents and not the collection schema./collections/{collectionName}/{documentId}
becomes/collections/{collectionName}/documents/{documentId}
to keep it contained within thedocuments
namespace within collections.API Request:
:
(colon) in the search endpoint'sfilter_by
andsort_by
fields since colons can't be part of URLs as per spec. They need to be URL encoded.API Response:
/collections
response, it currently only returns two attributes of a collection (name
andnum_documents
). We should just return all attributes for the collection entity, for all entities. This way the response is consistent anytime a collection shows up in the response./collections
endpoint response is nested under a root-level attribute calledcollections
. We should return an array ofcollection
objects as the response.A couple of other general observations:
_highlight
field inside the document, which seems a little odd to me. How about instead something like this:/export
end-point returns JSON lines format? Does it stream the output line-by-line? It would make the API more consistent if we just returned an array of documents that people can then parse using sayjq
.