# Query string query from javascript client

**URL:** <https://discuss.elastic.co/t/query-string-query-from-javascript-client/235084>\
**Category:** Elasticsearch\
**Created:** [May 31, 2020, 7:04pm UTC](https://discuss.elastic.co/t/query-string-query-from-javascript-client/235084 "2020-05-31T19:04:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yazhini\_ravi](https://avatars.discourse-cdn.com/v4/letter/y/838e76/32.png) [@yazhini\_ravi](https://discuss.elastic.co/u/yazhini_ravi)\
**Post date:** [May 31, 2020, 7:04pm UTC](https://discuss.elastic.co/t/query-string-query-from-javascript-client/235084/1 "2020-05-31T19:04:29Z")

</div>

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?

---

<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:** [June 28, 2020, 7:04pm UTC](https://discuss.elastic.co/t/query-string-query-from-javascript-client/235084/2 "2020-06-28T19:04:49Z")

</div>

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