# Not able to do request body search using rest client elasticsearch 5.4

**URL:** <https://discuss.elastic.co/t/not-able-to-do-request-body-search-using-rest-client-elasticsearch-5-4/88651>\
**Category:** Elasticsearch\
**Created:** [June 8, 2017, 5:14am UTC](https://discuss.elastic.co/t/not-able-to-do-request-body-search-using-rest-client-elasticsearch-5-4/88651 "2017-06-08T05:14:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cchavda](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cchavda](https://discuss.elastic.co/u/cchavda)\
**Post date:** [June 8, 2017, 5:14am UTC](https://discuss.elastic.co/t/not-able-to-do-request-body-search-using-rest-client-elasticsearch-5-4/88651/1 "2017-06-08T05:14:34Z")

</div>

Hello All,  
I just started with elastic search. I am using latest 5.4 version and rest client of it in Spring. Although I am successful to do uri search but I want to use request body search and below is my Code but it is givind total:0 and also given equivalent uri search which give me total:4 result. Please help me.

* * *

**Request body Search code :=**

```
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200, "http")).build();
HttpEntity entity = new NStringEntity("{\n" +
        " \"query\" : {\n" +
        " \"term\" : { \"pdfData\" : \"ADMINISTRATOR\" }\n" +
        " }\n" +
        "}", ContentType.APPLICATION_JSON);
Response indexResponse = restClient.performRequest("POST",
        "/cha/elasticSearch/_search?pretty",Collections.<String, String>emptyMap(),entity);
System.out.println(EntityUtils.toString(indexResponse.getEntity()));
restClient.close();

```

* * *

**uri search code :=**

```
        RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
        Response indexResponse = restClient.performRequest("GET","/agd/elasticSearch/_search?pretty&q=pdfData:ADMINISTRATOR",Collections.<String, String>emptyMap());
        System.out.println(EntityUtils.toString(indexResponse.getEntity());       
        restClient.close();
```

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [June 9, 2017, 11:47am UTC](https://discuss.elastic.co/t/not-able-to-do-request-body-search-using-rest-client-elasticsearch-5-4/88651/2 "2017-06-09T11:47:11Z")

</div>

Hi,  
did you try running the same with curl or from the Kibana Console? I suspect that the problem is not in the way you use the REST client, but more in the query. Your search request with a request body looks good to me at first glance.

Cheers  
Luca

---

<div class="post-metadata">

**Author:** ![cchavda](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cchavda](https://discuss.elastic.co/u/cchavda)\
**Post date:** [June 9, 2017, 12:20pm UTC](https://discuss.elastic.co/t/not-able-to-do-request-body-search-using-rest-client-elasticsearch-5-4/88651/3 "2017-06-09T12:20:41Z")

</div>

Thanks for reply. Yes today only I tried another query and it worked.

---

<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 7, 2017, 12:20pm UTC](https://discuss.elastic.co/t/not-able-to-do-request-body-search-using-rest-client-elasticsearch-5-4/88651/4 "2017-07-07T12:20:44Z")

</div>

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