-
Notifications
You must be signed in to change notification settings - Fork 47
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
NDJSON/CSV methods to add and update documents #243
Comments
253: Remove Content-Type from non-body HTTP methods r=curquiza a=thicolares - The non-body HTTP methods: GET and DELETE. - Expose the headers as arg to make it explicit and move the decision/concern to each method instead of send_request. - Use keywords args as there're multiple optional ones. - Extract the non-body headers to a classes property to convey its intention with its name and reduce duplication. - Duly update related test. Closes the topic 1/3 of #243. It's a small step towards the other topics. Maybe they could even be bundled into a single PR, but I don't think it's mandatory. > Currently, the SDKs always send Content-Type: application/json to every request. Only the POST and PUT requests should send the Content-Type: application/json and not the DELETE and GET ones. Co-authored-by: Thiago Colares <[email protected]>
@curquiza qq about the new methods to ADD documents by type as I was checking the API docs:
|
Hello @thicolares
|
👆 Related to my previous message |
@curquiza yup, sure thing! Thanks for the answers! By default, I don't like long classes for multiple reasons, but there's no silver bullet and it may vary with the context and need. And yes, I'll try to change the minimum and stick to the scope :) |
@curquiza, there's a small thing we must fix and a solution I would like to align. To fixThis transformation to JSON introduces a small challenge to this task. And a lot of the SDK currently relies on it. Given we may send My suggested solution for nowExpose an option to explicitly tell when the body should be transformed or not. Motivations
Please, lemme know if you believe I'm missing something. My first commit will contain this change only. |
I'm not sure to concretely see what you mean, a PR would be better, but I can understand if you don't have the time :) do you mean a parameter?
Nope, we don't touch the user input regarding their dataset :) |
Definitely haha! I was coding in the meantime and was just trying to anticipate. I'll push it after tweaking RuboCop.
Perfect. That was my understanding from the code, but the previous tickets/conversation were a bit unclear to me |
257: Add methods to add JSON, CSV and NDJSON document r=curquiza a=thicolares ### Addresses the following items of #243: - [x] addDocumentsJson(string docs, string primaryKey) - [x] addDocumentsCsv(string docs, string primaryKey) - [x] addDocumentsNdjson(string docs, string primaryKey) ### Changes _Tip: in order to ease the code review, you can start reviewing it commit by commit._ - Expose request options as a parameter of `http_post`. Motivations: - Allow who knows about the content to use `transform_body?` in order to decide if `http_request` should or not transform the body to JSON; - Group `transform_body?`, `headers` and [other options' default values that were spread around](https://github.com/meilisearch/meilisearch-ruby/blob/1ddbc9253f15cc4879bd6e7392c145ae9af9bde9/lib/meilisearch/http_request.rb#L82-L83) into a single Hash; - It can be improved in the next iterations, but it will already ease the next tasks within #243. - Create methods to add documents as JSON, NDJSON and CSV - Add related tests exposing the usage of primaryKeys - No _"add in batches"_ included in this PR. Co-authored-by: Thiago Colares <[email protected]> Co-authored-by: Clémentine Urquizar - curqui <[email protected]>
Since this was merged, I will close it! |
add_documents_json
instead ofaddDocumentsJson
). Keep the already existing way of naming in this package to stay idiomatic with the language and this repository.📣 We strongly recommend doing multiple PRs to solve all the points of this issue
MeiliSearch v0.23.0 introduces two changes:
Content-type
header for every route requiring a payload (POST
andPUT
routes)Here are the expected changes to completely close the issue:
Currently, the SDKs always send
Content-Type: application/json
to every request. Only thePOST
andPUT
requests should send theContent-Type: application/json
and not theDELETE
andGET
ones. Add methods to add JSON, CSV and NDJSON document #257Add the following methods and 🔥 the associated tests 🔥 to ADD the documents. Depending on the format type (
csv
orndjson
) the SDK should sendContent-Type: application/x-dnjson
orContent-Type: text/csv
)addDocumentsJson(string docs, string primaryKey)
Add methods to add JSON, CSV and NDJSON document #257addDocumentsCsv(string docs, string primaryKey)
Add methods to add JSON, CSV and NDJSON document #257addDocumentsCsvInBatches(string docs, int batchSize, string primaryKey)
addDocumentsNdjson(string docs, string primaryKey)
Add methods to add JSON, CSV and NDJSON document #257addDocumentsNdjsonInBatches(string docs, int batchSize, string primaryKey)
Add the following methods and 🔥 the associated tests 🔥 to UPDATE the documents. Depending on the format type (
csv
orndjson
) the SDK should sendContent-Type: application/x-dnjson
orContent-Type: text/csv
)updateDocumentsJson(string docs, string primaryKey)
updateDocumentsCsv(string docs, string primaryKey)
updateDocumentsCsvInBatches(string docs, int batchSize, string primaryKey)
updateDocumentsNdjson(string docs, string primaryKey)
updateDocumentsNdjsonInBatches(string docs, int batchSize, string primaryKey)
docs
are the documents sent asString
primaryKey
is the primary key of the indexbatchSize
is the size of the batch. Example: you can send 2000 documents in raw String indocs
and ask for abatchSize
of 1000, so your documents will be sent to MeiliSearch in two batches.Example of PRs:
CSV
NDJSON
meilisearch-python#329Related to: meilisearch/integration-guides#146
If this issue is partially/completely implemented, feel free to let us know.
The text was updated successfully, but these errors were encountered: