putScript issue

   const s = await client.putScript({
      id: 'appendToDirectChat',
      lang: 'painless',
      body: {
        script: 'ctx._source.directChats = (ctx._source.directChats) ? ctx._source.directChats + user : [user]'
      }
    })

Anyone got any hints as to why this errors?

(node:72851) Error: [script_exception] compile error, with { script_stack={ 0="... tx._source.directChats + user : [user]" & 1=" ^---- HERE" } & script="ctx._source.directChats = (ctx._source.directChats) ? ctx._source.directChats + user : [user]" & lang="painless" }
at respond (/Users/jt/dev/mono/packages/service-indexing/node_modules/elasticsearch/src/lib/transport.js:307:15)
at checkRespForFailure (/Users/jt/dev/mono/packages/service-indexing/node_modules/elasticsearch/src/lib/transport.js:266:7)
at HttpConnector. (/Users/jt/dev/mono/packages/service-indexing/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
at IncomingMessage.bound (/Users/jt/dev/mono/packages/service-indexing/node_modules/lodash/dist/lodash.js:729:21)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:72851) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitWarning (internal/process/promises.js:71:15)
at emitPendingUnhandledRejections (internal/process/promises.js:88:11)
at process._tickCallback (internal/process/next_tick.js:189:7)

1 Like

Javascript SDK - elasticsearch@13.3.1

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