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

Can't use asStream with body on v8 but docs say we can #2241

Closed
tomimarkus991 opened this issue Apr 29, 2024 · 2 comments
Closed

Can't use asStream with body on v8 but docs say we can #2241

tomimarkus991 opened this issue Apr 29, 2024 · 2 comments

Comments

@tomimarkus991
Copy link

Elasticsearch Version

v8.13

Installed Plugins

@elastic/elasticsearch

Java Version

bundled

OS Version

Darwin ip-192-168-0-21.eu-north-1.compute.internal 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 arm64

Problem Description

https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/8.13/as_stream_examples.html

Docs say to use body but there is no body on result.

using regular payload is not working

Steps to Reproduce

try to add asStream to search and use body.

Logs (if relevant)

No response

@DaveCTurner DaveCTurner transferred this issue from elastic/elasticsearch Apr 29, 2024
JoshMock added a commit that referenced this issue Apr 30, 2024
#2241 notes that there
is no body attribute on a response. This is mostly just a typo in the
example, as `result` itself is a readable stream, unless `meta: true` is
passed, in which case `result.body` will be a readable stream.

Also dropped the callback-style stream processing example as it's a bit
outdated.
@JoshMock
Copy link
Member

Thanks for the question @tomimarkus991. I think the issue here is that the code example was a bit confusing, as result is the value that should be operated on, not body. The return value of an API request is itself a ReadableStream when asStream is enabled. Unless you are also passing meta: true, in which case the response will be an object whose body property is a ReadableStream.

I updated the code example in #2242 to make that more clear. I was able to run the updated code snippet verbatim against a local 8.13.0 Elasticsearch instance and it worked perfectly.

@tomimarkus991
Copy link
Author

thanks alot

JoshMock added a commit that referenced this issue Apr 30, 2024
#2241 notes that there
is no body attribute on a response. This is mostly just a typo in the
example, as `result` itself is a readable stream, unless `meta: true` is
passed, in which case `result.body` will be a readable stream.

Also dropped the callback-style stream processing example as it's a bit
outdated.
github-actions bot pushed a commit that referenced this issue Apr 30, 2024
#2241 notes that there
is no body attribute on a response. This is mostly just a typo in the
example, as `result` itself is a readable stream, unless `meta: true` is
passed, in which case `result.body` will be a readable stream.

Also dropped the callback-style stream processing example as it's a bit
outdated.

(cherry picked from commit 45e3c06)
github-actions bot pushed a commit that referenced this issue Apr 30, 2024
#2241 notes that there
is no body attribute on a response. This is mostly just a typo in the
example, as `result` itself is a readable stream, unless `meta: true` is
passed, in which case `result.body` will be a readable stream.

Also dropped the callback-style stream processing example as it's a bit
outdated.

(cherry picked from commit 45e3c06)
JoshMock added a commit that referenced this issue Apr 30, 2024
#2241 notes that there
is no body attribute on a response. This is mostly just a typo in the
example, as `result` itself is a readable stream, unless `meta: true` is
passed, in which case `result.body` will be a readable stream.

Also dropped the callback-style stream processing example as it's a bit
outdated.

(cherry picked from commit 45e3c06)

Co-authored-by: Josh Mock <[email protected]>
JoshMock added a commit that referenced this issue Apr 30, 2024
#2241 notes that there
is no body attribute on a response. This is mostly just a typo in the
example, as `result` itself is a readable stream, unless `meta: true` is
passed, in which case `result.body` will be a readable stream.

Also dropped the callback-style stream processing example as it's a bit
outdated.

(cherry picked from commit 45e3c06)

Co-authored-by: Josh Mock <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants