Dynamic Elasticsearch query execution from Node JS

I need to execute dynamic queries from Node JS . I tried the following script and getting error.

async function executeDynamicTest (){
const querySrting= "{index: 'entity_index', query: { match: { amount: '1819' }}}";
console.log(JSON.parse(JSON.stringify(querySrting))) ;

   const document = await client.search({
      body: JSON.parse(JSON.stringify(querySrting))
})
console.log(document.hits.hits);

}

The error I got is as mentioned below.

ResponseError: {"error":"Content-Type header [text/plain] is not supported","status":406}

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