# Java Rest API doesn't work as expected

**URL:** <https://discuss.elastic.co/t/java-rest-api-doesnt-work-as-expected/84562>\
**Category:** Elasticsearch\
**Created:** [May 4, 2017, 1:29pm UTC](https://discuss.elastic.co/t/java-rest-api-doesnt-work-as-expected/84562 "2017-05-04T13:29:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vardang](https://avatars.discourse-cdn.com/v4/letter/v/97f17d/32.png) [@vardang](https://discuss.elastic.co/u/vardang)\
**Post date:** [May 4, 2017, 1:29pm UTC](https://discuss.elastic.co/t/java-rest-api-doesnt-work-as-expected/84562/1 "2017-05-04T13:29:18Z")

</div>

Hi there,

I'm using mapper plugin to index pdf files, and in Kibana console everything works as expected.  
I've tried following request, and ElasticSearch responses with 2 documents:  
`
POST /reports/generated/_search?filter_path=hits.hits._source
{
"query":{
"query_string":{
"query":"USD"
}
}
}
`  
Both pdfs contain "USD" word.  
But I do the same thing with Java REST API and ElasticSearch cannot make a search in the indexed pdfs.  
For querying I'm using following java code:  
`
String query = "{"query":{"query_string":{"query":"" + "USD" + ""}}}";
Response response = restClient.performRequest(
"POST",
"/reports/generated/_search?filter_path=hits.hits._source",
new Hashtable<>(),
new StringEntity(query));
`

When I change "USD" querying string with another value, which contains another field (not the attachment), then everything is working well. So do I need some configuration in my java restClient to enable context searching in the indexed pdfs?

Thanks,  
Vardan

---

<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 1, 2017, 1:30pm UTC](https://discuss.elastic.co/t/java-rest-api-doesnt-work-as-expected/84562/2 "2017-06-01T13:30:00Z")

</div>

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