Query string query from javascript client

Hi,
I am using elasticsearch 5.5 and my query is

"query":{
"query_string": {
"query": "state:MD AND city:Baltimore AND postalcode:12345"
}
}
This query works fine in kibana. But I use javascript API to execute the same query with user given values like

client.search({
index: 'sample',
type: 'data',
body:{
"query":{
"query_string": {
"query": "state:req.params.state AND city:req.params.city AND postalcode:req.params.pc"
}
}
}
}
})
In this code req.params.state, req.params.city and req.params.pc are user given values which are considered as value(string) itself and returns nothing because double quotes are used.So when I tried to remove double quotes the AND operater used is not validated as operator and thows an error.

I have used escaping characters but it doesnt work.Can anyone help me solve this problem?

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