-
Notifications
You must be signed in to change notification settings - Fork 123
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
[FEATURE] Where can I find some sample about how to use bulk api to upload documents? #259
Comments
I think @zhaoyi0113 is looking for a working sample that uses opensearch-js to call the bulk API. Anyone? |
This is what I did. It's javascript and it's quick and garbage code but maybe it'll help :-) Something about POST bulk indexes need to be separated by newlines? I'm not sure the full story behind this.
I should add that I'm not 100% sure this works. It says it did but I just haven't queried the index yet. I also think this should be a core part of the documentation. Maybe I'll open a PR. |
Here's a code snippet to bulk upload documents. var bulk_documents = [
{
index: {
_index: 'books-king',
_id: '2'
}
},
{
title: 'IT',
author: 'Stephen Kings',
year: '1986',
},
{
create: {
_index: 'test',
_id: '3'
}
},
{
title: 'The Green Mile',
author: 'Stephen Kings',
year: '1996',
},
{
create: {
_index: 'test',
_id: '4'
}
},
{
title: 'Carrie',
author: 'Stephen Kings',
year: '1974',
}
];
var response = await client.bulk({ body: bulk_documents });
console.log(response.body); Will try to add some documentation in the |
Tracked in #277 |
@wbeckler @VachaShah I believe safe to close this one. |
I am trying to use
bulk
API to upload many documents in one request. But I keep getReason: request body is required"
error response. Is there any document I can see how to set the parameter correctly?I am using below code to upload the documents.
The text was updated successfully, but these errors were encountered: