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

[BUG] Documentation shows onDocument can accept an array as a return but that throws an error #551

Open
dtaivpp opened this issue Jul 12, 2023 · 1 comment
Labels
🐛 bug Something isn't working

Comments

@dtaivpp
Copy link

dtaivpp commented Jul 12, 2023

What is the bug?

Hey all, when attempting to use this code it tells me that an array is an invalid return type. Is this an issue with the JS library or with the documentation?

https://github.com/opensearch-project/documentation-website/blob/02f40d7efd4265e85c128d0a85a65c668c016b97/_clients/javascript/helpers.md?plain=1#L96C8-L102

How can one reproduce the bug?

let result = await os_client.helpers.bulk({
    datasource: [{ body: "this is my text", id: 1234}],
    onDocument (doc) {
      return [
      {
          index: { _index: index_name , _id: doc.id }
       }, 
       {...doc, body: "instead have this body"}
     ]
    }

What is the expected behavior?

I would expect this to modify the body of the document and add it as a bulk action.

What is your host/environment?

MacOS

Do you have any screenshots?

Screenshot 2023-07-12 at 3 57 35 PM

Do you have any additional context?

Add any other context about the problem.

@nhtruong
Copy link
Collaborator

I can't recreate your error. What version of the client are you using? Does the trace log point out where the error occurs?

@wbeckler wbeckler added the 🐛 bug Something isn't working label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants