How to pass a variable to elasticsearch query javascript

Hi,
I am a nebie to ElasticSearch. I have searched for an answer to this question before making this post.

I am trying to run an ElasticSearch query from a JavaScript app using a variable for the search string. I have been unable to make it work. Below you will find is a relevant code snippet, which does not work.

I would appreciate it if someone could point me in the direction of a solution to this problem.

Thank you,

Alex Donnini

===============================================
var myGpsLatitudeTruncated = myGpsLatitudeMyLongitudeTruncated.substring(4, myGpsLatitudeMyLongitudeTruncated.indexOf(',')).trim();

	const query = {
		    "page": 1,
		    "offset": 100,
		    "query": {
		        "nativeSearch": 1,
		        "query_string": {
		            "query": "(service.attributes.additionalInformation.workExample:'${myGpsLatitudeTruncated}'*) -isInPurgatory:true",
		                  "analyze_wildcard": true
		        }
		    },
		    "sort": {
		        "created": -1
		    }
		};

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