# Possible Bug in Java API 0.19.0.RC2? Query works in elasticsearch-head, fails in java app

**URL:** <https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737>\
**Category:** Elasticsearch\
**Created:** [February 17, 2012, 5:41pm UTC](https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737 "2012-02-17T17:41:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![George\_L](https://avatars.discourse-cdn.com/v4/letter/g/ee7513/32.png) [@George\_L](https://discuss.elastic.co/u/George_L)\
**Post date:** [February 17, 2012, 5:41pm UTC](https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737/1 "2012-02-17T17:41:22Z")

</div>

Hello,

The below query was built using java api and when tried in the app,  
it comes back with zero hits and facets.  
But the same query when cut/paste into the elasticsearch-head tool, it  
comes back with proper hits and facets.

I just need to know whether its a valid query or which one is correct,  
java api or json post.

Thanks  
George

Below is the query

{  
"from" : 0,  
"size" : 2,  
"query" : {  
"filtered" : {  
"query" : {  
"match\_all" : {  
}  
},  
"filter" : {  
"bool" : {  
"must" : {  
"term" : {  
"paths" : "/1"  
}  
}  
}  
}  
}  
},  
"facets" : {  
"paths" : {  
"terms" : {  
"field" : "paths",  
"size" : 100,  
"regex" : "/1/[^/]+"  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 17, 2012, 5:48pm UTC](https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737/2 "2012-02-17T17:48:09Z")

</div>

It looks good. Can you repro the failed Java code in a standalone test?

On Friday, February 17, 2012 at 7:41 PM, George L wrote:

> Hello,
> 
> The below query was built using java api and when tried in the app,  
> it comes back with zero hits and facets.  
> But the same query when cut/paste into the elasticsearch-head tool, it  
> comes back with proper hits and facets.
> 
> I just need to know whether its a valid query or which one is correct,  
> java api or json post.
> 
> Thanks  
> George
> 
> Below is the query
> 
> {  
> "from" : 0,  
> "size" : 2,  
> "query" : {  
> "filtered" : {  
> "query" : {  
> "match\_all" : {  
> }  
> },  
> "filter" : {  
> "bool" : {  
> "must" : {  
> "term" : {  
> "paths" : "/1"  
> }  
> }  
> }  
> }  
> }  
> },  
> "facets" : {  
> "paths" : {  
> "terms" : {  
> "field" : "paths",  
> "size" : 100,  
> "regex" : "/1/[^/]+"  
> }  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![George\_L](https://avatars.discourse-cdn.com/v4/letter/g/ee7513/32.png) [@George\_L](https://discuss.elastic.co/u/George_L)\
**Post date:** [February 17, 2012, 9:14pm UTC](https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737/3 "2012-02-17T21:14:09Z")

</div>

Not a Bug, Probably a suggestion.

It was a development mistake, set a wrong document type in the  
SearchRequestBuilder.

The toString() of SearchRequestBuilder doesn't print the document type  
or index.

This took time to figure out the problem.

Thanks  
George

On Feb 17, 11:48 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> It looks good. Can you repro the failed Java code in a standalone test?
> 
> On Friday, February 17, 2012 at 7:41 PM, George L wrote:
> 
> > Hello,
> 
> > The below query was built using java api and when tried in the app,  
> > it comes back with zero hits and facets.  
> > But the same query when cut/paste into the elasticsearch-head tool, it  
> > comes back with proper hits and facets.
> 
> > I just need to know whether its a valid query or which one is correct,  
> > java api or json post.
> 
> > Thanks  
> > George
> 
> > Below is the query
> 
> > {  
> > "from" : 0,  
> > "size" : 2,  
> > "query" : {  
> > "filtered" : {  
> > "query" : {  
> > "match\_all" : {  
> > }  
> > },  
> > "filter" : {  
> > "bool" : {  
> > "must" : {  
> > "term" : {  
> > "paths" : "/1"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "facets" : {  
> > "paths" : {  
> > "terms" : {  
> > "field" : "paths",  
> > "size" : 100,  
> > "regex" : "/1/[^/]+"  
> > }  
> > }  
> > }  
> > }

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 17, 2012, 10:49pm UTC](https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737/4 "2012-02-17T22:49:46Z")

</div>

Ahh, yea, it just prints out the "body" of the request. Open an issue? Can be added easily.

On Friday, February 17, 2012 at 11:14 PM, George L wrote:

> Not a Bug, Probably a suggestion.
> 
> It was a development mistake, set a wrong document type in the  
> SearchRequestBuilder.
> 
> The toString() of SearchRequestBuilder doesn't print the document type  
> or index.
> 
> This took time to figure out the problem.
> 
> Thanks  
> George
> 
> On Feb 17, 11:48 am, Shay Banon \<[kim...@gmail.com](mailto:kim...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> 
> > It looks good. Can you repro the failed Java code in a standalone test?
> > 
> > On Friday, February 17, 2012 at 7:41 PM, George L wrote:
> > 
> > > Hello,
> > 
> > > The below query was built using java api and when tried in the app,  
> > > it comes back with zero hits and facets.  
> > > But the same query when cut/paste into the elasticsearch-head tool, it  
> > > comes back with proper hits and facets.
> > 
> > > I just need to know whether its a valid query or which one is correct,  
> > > java api or json post.
> > 
> > > Thanks  
> > > George
> > 
> > > Below is the query
> > 
> > > {  
> > > "from" : 0,  
> > > "size" : 2,  
> > > "query" : {  
> > > "filtered" : {  
> > > "query" : {  
> > > "match\_all" : {  
> > > }  
> > > },  
> > > "filter" : {  
> > > "bool" : {  
> > > "must" : {  
> > > "term" : {  
> > > "paths" : "/1"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > },  
> > > "facets" : {  
> > > "paths" : {  
> > > "terms" : {  
> > > "field" : "paths",  
> > > "size" : 100,  
> > > "regex" : "/1/[^/]+"  
> > > }  
> > > }  
> > > }  
> > > }

---

<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 6, 2017, 3:38am UTC](https://discuss.elastic.co/t/possible-bug-in-java-api-0-19-0-rc2-query-works-in-elasticsearch-head-fails-in-java-app/6737/5 "2017-07-06T03:38:52Z")

</div>


