Skip to content
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 #182

Closed
13 tasks done
curquiza opened this issue Oct 19, 2021 · 5 comments · Fixed by #274
Closed
13 tasks done

NDJSON/CSV methods to add and update documents #182

curquiza opened this issue Oct 19, 2021 · 5 comments · Fixed by #274
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@curquiza
Copy link
Member

curquiza commented Oct 19, 2021

⚠️ This issue is generated, it means the nameing might be done differently in this package (ex: add_documents_json instead of addDocumentsJson). 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:

  • new valid formats to push data files, additionally to the JSON format: CSV and NDJSON formats.
  • it enforces the Content-type header for every route requiring a payload (POST and PUT routes)

Here are the expected changes to completely close the issue:

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

  • Add the following methods and 🔥 the associated tests 🔥 to ADD the documents. Depending on the format type (csv or ndjson) the SDK should send Content-Type: application/x-dnjson or Content-Type: text/csv)

    • addDocumentsJson(string docs, string primaryKey)
    • addDocumentsCsv(string docs, string primaryKey)
    • addDocumentsCsvInBatches(string docs, int batchSize, string primaryKey)
    • addDocumentsNdjson(string docs, string primaryKey)
    • addDocumentsNdjsonInBatches(string docs, int batchSize, string primaryKey)
  • Add the following methods and 🔥 the associated tests 🔥 to UPDATE the documents. Depending on the format type (csv or ndjson) the SDK should send Content-Type: application/x-dnjson or Content-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 as String
primaryKey is the primary key of the index
batchSize is the size of the batch. Example: you can send 2000 documents in raw String in docs and ask for a batchSize of 1000, so your documents will be sent to MeiliSearch in two batches.

Example of PRs:


Related to: meilisearch/integration-guides#146

If this issue is partially/completely implemented, feel free to let us know.

EDIT:

The files needed for the tests when creating the csv and ndjson methods are available here:

@curquiza curquiza added hacktoberfest good first issue Good for newcomers enhancement New feature or request labels Oct 19, 2021
@iverburgh
Copy link

Currently working on this issue

@curquiza
Copy link
Member Author

Hello @iverburgh

Thanks for your interest in this project :)

Just FYI, we prefer not assigning people to our issues because sometimes people ask to be assigned and never come back, which discourages the volunteer contributors to open a PR to fix this issue.
We will accept and merge the first PR that fixes correctly and well implements the issue following our contributing guidelines.

We are looking forward to reviewing your PR 🙂

@juchom
Copy link
Contributor

juchom commented Jan 10, 2022

Hello @curquiza

I'm having a look at this issue and the first item to fix it this one

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.

Can you point me some code where GET or DELETE calls are sending Content-Type ?

I runned the tests with Fiddler and I have this for the calls I have checked :

GET
image

DELETE
image

@curquiza
Copy link
Member Author

Hello @juchom

sorry it's indeed not the case sorry! It has been fixed!

bors bot added a commit that referenced this issue May 25, 2022
269: Add support for JSON string r=alallema a=juchom

# Pull Request

## What does this PR do?
Fixes JSON string support in #182

This adds support for JSON string Add and Update.

For the tests I introduced the sample files used in other repo.

Co-authored-by: Julien Chomarat <[email protected]>
bors bot added a commit that referenced this issue May 30, 2022
272: Add support for documents as CSV string r=alallema a=juchom

# Pull Request

## What does this PR do?
Fixes partially  #182

This one is for the support of CSV string content

Co-authored-by: Julien Chomarat <[email protected]>
@bors bors bot closed this as completed in c8aacc3 May 31, 2022
@bors bors bot closed this as completed in #274 May 31, 2022
@alallema
Copy link
Contributor

Well Done @juchom 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
5 participants