Elasticsearch nodejs client 8.2 msearch error

We have been using elastic node js client version 8.1.0 and updated to @elastic/Elasticsearch@8.2.0.
Suddently our msearch query stopped working with

ResponseError: illegal_argument_exception: [illegal_argument_exception] Reason: The msearch request must be terminated by a newline [ ]
 at SniffingTransport.request 
 at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Client.MsearchApi [as msearch] (xxx/node_modules/@elastic/elasticsearch/lib/api/api/msearch.js:51:12)

Our syntax didn't change and I haven't found that ES would change syntax.

I am auto-generating all msearch queries with

requestList.push(
          {
            index: requests[j].index     //index name as string
          },
          requests[j].query      //predefine json templates {query: {bool: xxx}}
        );

and than putting it into msearch

const response = await client.msearch({
        searches: requestList
      })

I tried to stringify and add \n at the end of body (or after index) but didn't work. Any idea what to do?

Hello! This is a bug present in the v8.2.0 release (see Bulk request broken on 8.2.0, "The bulk request must be terminated by a newline [\\n]" error · Issue #1686 · elastic/elasticsearch-js · GitHub). It has been fixed in Fix ndjson APIs by delvedor · Pull Request #1688 · elastic/elasticsearch-js · GitHub, and it will be released in v8.2.1 soon.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.