Cryptic error trying to test a PROD-ready query proxy

Greetings again, Stretchy-lookers!

I’ve run into a problem trying to derive my use case from the following tutorial:

Note: I’m not looking to do any User Behavior Insights (UBI), so I’ve trimmed the example down a lot.

The following is the Express-based proxy server I’m using:

import express from 'express'
import ElasticsearchAPIConnector from '@elastic/search-ui-elasticsearch-connector'
import 'dotenv/config'
import cors from 'cors'

const app = express()
app.use(express.json())
app.use(cors())

const connector = new ElasticsearchAPIConnector({
  host: process.env.ELASTICSEARCH_HOST,
  index: process.env.ELASTICSEARCH_INDEX,
});

app.post("/api/search", async (req, res) => {
  if (!('state' in req.body) || !('queryConfig' in req.body)) {
    res.status(400).json('{"errorMessage":"Missing parameter(s)"}')
    console.warn('received request w/ missing param(s)')
    return
  }
  const { state, queryConfig } = req.body
  const response = await connector.onSearch(state, queryConfig)
  res.json(response)
});

app.listen(
  process.env.API_PORT,
  () => console.log(`web server listening on port ${process.env.API_PORT}`)
)

Meanwhile, the “cluster” I’m using is just a Docker container instantiated by:

docker run \
   --rm \
   -p 9201:9200 \
   -p 9301:9300 \
   -e "discovery.type=single-node" \
   -e "xpack.security.enabled=false" \
   -e "xpack.security.enrollment.enabled=false" \
   -e "path.repo=/mount/backups" \
   --mount type=bind,source=./es-cluster-backup,target=/mount/backups \
   --mount type=bind,source=./es-data,target=/usr/share/elasticsearch/data \
   docker.elastic.co/elasticsearch/elasticsearch:9.3.0

which is populated with the bulk book data from the tutorial I linked above.

And to test:

curl -v \
-X POST \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{"state":{"current":1,"filters":[],"resultsPerPage":20,"searchTerm":"atwood","sortDirection":"","sortField":"","sortList":[]},"queryConfig":{"disjunctiveFacets":[],"disjunctiveFacetsAnalyticsTags":[],"facets":{},"filters":[],"fuzziness":true,"result_fields":{"author":{"raw":{}},"name":{"raw":{}},"release_date":{"raw":{}}},"search_fields":{"author":{},"name":{}}}}' \
http://localhost:${API_PORT}/api/search

But this generates the following error in the Express proxy, causing it to crash:

TypeError: Cannot read properties of undefined (reading 'total')

Any insight would be appreciated.