# Restful API query string has http 500 error code

**URL:** <https://discuss.elastic.co/t/restful-api-query-string-has-http-500-error-code/281808>\
**Category:** Elasticsearch\
**Created:** [August 18, 2021, 10:20am UTC](https://discuss.elastic.co/t/restful-api-query-string-has-http-500-error-code/281808 "2021-08-18T10:20:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [August 18, 2021, 10:20am UTC](https://discuss.elastic.co/t/restful-api-query-string-has-http-500-error-code/281808/1 "2021-08-18T10:20:04Z")

</div>

The query String in Kibana is : `system:APC AND host: F12*R2R* AND message:"Turn to Phase [F12P7]"`, and I want to query through Restful API like below:

```
			String bodycontent="{"
				+" \"_source\": [\"@timestamp\",\"eqpid\",\"lotid\",\"stageid\"],"
				+" \"query\": {"
				+" \"bool\":{"
				+"	\"must\":[{"
				+" \"query_string\" : {"
				+" \"query\": \"(system:APC) AND (host:F12*R2R*) AND (message:\*Turn to Phase [F12P7]\*)\"}"
				+" },{"
				+" \"range\":{"
				+" \"@timestamp\":{"
				+" \"gte\":\""+start+"\","
				+"	\"lte\":\""+end+"\"}"
				+" }"
				+ "}]}},"
				+" \"sort\" : [{\"@timestamp\" : { \"order\" : \"desc\" }}]"
				+"}";

```

I have tested below code is work(delete `AND (message:\*Turn to Phase [F12P7]\*)`):

```
    			String bodycontent="{"
				+" \"_source\": [\"@timestamp\",\"eqpid\",\"lotid\",\"stageid\"],"
				+" \"query\": {"
				+" \"bool\":{"
				+"	\"must\":[{"
				+" \"query_string\" : {"
				+" \"query\": \"(system:APC) AND (host:F12*R2R*)\"}"
				+" },{"
				+" \"range\":{"
				+" \"@timestamp\":{"
				+" \"gte\":\""+start+"\","
				+"	\"lte\":\""+end+"\"}"
				+" }"
				+ "}]}},"
				+" \"sort\" : [{\"@timestamp\" : { \"order\" : \"desc\" }}]"
				+"}";

```

but HTTP response 500 error code, the message raw data is like below:

XXXXXXXXXXX XXXXX XX XXX  
XXXXXXXXXXXXX XX XXXX  
XXXXXXXX  
XXX Ack=0 Description="No valid MAPId [LGSQ123] exists. Turn to Phase [F12P7]" XXXX  
XXXX XXXXXXXXXXXX XXXX

How could I query the specified string in the message?  
thanks in advance !

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2021, 10:15am UTC](https://discuss.elastic.co/t/restful-api-query-string-has-http-500-error-code/281808/2 "2021-08-25T10:15:17Z")

</div>

that message does not look like an Elasticsearch exception, please check what the Elasticsearch side is returning to the client and share it here (must be JSON).

---

<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:** [September 22, 2021, 10:15am UTC](https://discuss.elastic.co/t/restful-api-query-string-has-http-500-error-code/281808/3 "2021-09-22T10:15:49Z")

</div>

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