# Passing JavaScript Object to ElasticSearch query

**URL:** <https://discuss.elastic.co/t/passing-javascript-object-to-elasticsearch-query/186673>\
**Category:** Elasticsearch\
**Created:** [June 20, 2019, 12:07pm UTC](https://discuss.elastic.co/t/passing-javascript-object-to-elasticsearch-query/186673 "2019-06-20T12:07:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiimcarsten](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@hiimcarsten](https://discuss.elastic.co/u/hiimcarsten)\
**Post date:** [June 20, 2019, 12:07pm UTC](https://discuss.elastic.co/t/passing-javascript-object-to-elasticsearch-query/186673/1 "2019-06-20T12:07:08Z")

</div>

Solved: you can just pass a JavaScript object. Not sure what my mistake was but it's working now.

* * *

Hi Everyone,

Summary:  
Can't figure out how to pass real-time data with JavaScript objects to ElasticSearch query.

Context:  
I run NodeJS with Elastic. I have an ElasticSearch document with a product and a price. Now I want to see the profit in real-time. I store the real-time prices in a JavaScript object. I want to send the JS object as a param in the scripted\_metric scripts.

Is this possible? Simple values like numbers work fine.

The JS Object looks like this:  
{ 'productName': {  
'price': 5  
},  
'anotherProductName': {  
'price': 4  
}  
}

---

<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:** [July 18, 2019, 12:07pm UTC](https://discuss.elastic.co/t/passing-javascript-object-to-elasticsearch-query/186673/2 "2019-07-18T12:07:09Z")

</div>

Closed on July 18, 2019, 12:07pm UTC

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