# Dynamic Elasticsearch query execution from Node JS

**URL:** <https://discuss.elastic.co/t/dynamic-elasticsearch-query-execution-from-node-js/317602>\
**Category:** Elasticsearch\
**Created:** [October 27, 2022, 10:55am UTC](https://discuss.elastic.co/t/dynamic-elasticsearch-query-execution-from-node-js/317602 "2022-10-27T10:55:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pravu](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pravu](https://discuss.elastic.co/u/pravu)\
**Post date:** [October 27, 2022, 10:55am UTC](https://discuss.elastic.co/t/dynamic-elasticsearch-query-execution-from-node-js/317602/1 "2022-10-27T10:55:43Z")

</div>

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}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 24, 2022, 10:56am UTC](https://discuss.elastic.co/t/dynamic-elasticsearch-query-execution-from-node-js/317602/2 "2022-11-24T10:56:17Z")

</div>

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