# Query run via Java API fails

**URL:** <https://discuss.elastic.co/t/query-run-via-java-api-fails/14353>\
**Category:** Elasticsearch\
**Created:** [November 11, 2013, 3:22pm UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353 "2013-11-11T15:22:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Pinette](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kyle_pinette/32/1975_2.png) [@Kyle\_Pinette](https://discuss.elastic.co/u/Kyle_Pinette)\
**Post date:** [November 11, 2013, 3:22pm UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353/1 "2013-11-11T15:22:42Z")

</div>

Hey Guys,

I'm trying to use the Query / Filter Builder objects with the Java API.  
However, when I execute a query using these it is failing. If I take the  
JSON output that the Query / Filter Builders generate and run them via the  
REST API, the query succeeds. I have no clue how to debug what is going on  
here.

The error message I'm getting is:

nested: QueryParsingException[[db\_name] Failed to find geo\_shape field

> [searchGeometry]]

As you can see here, the geo\_shape mapping does exist:

> <https://gist.github.com/sowelie/2e626fc6cfd8d9f91c8a>

Also, here is the query:

> <https://gist.github.com/sowelie/f74fc81b7e957b5d2022>

Any help would be much appreciated.

-Kyle

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Kyle\_Pinette](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kyle_pinette/32/1975_2.png) [@Kyle\_Pinette](https://discuss.elastic.co/u/Kyle_Pinette)\
**Post date:** [November 11, 2013, 5:33pm UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353/2 "2013-11-11T17:33:12Z")

</div>

For now, I've worked around this by not using the query builders, but by  
generating the JSON for queries using XContentBuilder.

On Monday, November 11, 2013 10:22:42 AM UTC-5, Kyle Pinette wrote:

> Hey Guys,
> 
> I'm trying to use the Query / Filter Builder objects with the Java API.  
> However, when I execute a query using these it is failing. If I take the  
> JSON output that the Query / Filter Builders generate and run them via the  
> REST API, the query succeeds. I have no clue how to debug what is going on  
> here.
> 
> The error message I'm getting is:
> 
> nested: QueryParsingException[[db\_name] Failed to find geo\_shape field
> 
> > [searchGeometry]]
> 
> As you can see here, the geo\_shape mapping does exist:
> 
> [curl -XGET http://localhost:9200/new\_il\_vectordb/layer\_0/\_mapping · GitHub](https://gist.github.com/sowelie/2e626fc6cfd8d9f91c8a)
> 
> Also, here is the query:
> 
> [es\_error\_query.json · GitHub](https://gist.github.com/sowelie/f74fc81b7e957b5d2022)
> 
> Any help would be much appreciated.
> 
> -Kyle

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [November 13, 2013, 2:47pm UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353/3 "2013-11-13T14:47:06Z")

</div>

Would be nice to understand what the problem was and fix it. Can you maybe  
post the java code that triggers the error?

On Monday, November 11, 2013 6:33:12 PM UTC+1, Kyle Pinette wrote:

> For now, I've worked around this by not using the query builders, but by  
> generating the JSON for queries using XContentBuilder.
> 
> On Monday, November 11, 2013 10:22:42 AM UTC-5, Kyle Pinette wrote:
> 
> > Hey Guys,
> > 
> > I'm trying to use the Query / Filter Builder objects with the Java API.  
> > However, when I execute a query using these it is failing. If I take the  
> > JSON output that the Query / Filter Builders generate and run them via the  
> > REST API, the query succeeds. I have no clue how to debug what is going on  
> > here.
> > 
> > The error message I'm getting is:
> > 
> > nested: QueryParsingException[[db\_name] Failed to find geo\_shape field
> > 
> > > [searchGeometry]]
> > 
> > As you can see here, the geo\_shape mapping does exist:
> > 
> > [curl -XGET http://localhost:9200/new\_il\_vectordb/layer\_0/\_mapping · GitHub](https://gist.github.com/sowelie/2e626fc6cfd8d9f91c8a)
> > 
> > Also, here is the query:
> > 
> > [es\_error\_query.json · GitHub](https://gist.github.com/sowelie/f74fc81b7e957b5d2022)
> > 
> > Any help would be much appreciated.
> > 
> > -Kyle

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [November 13, 2013, 4:01pm UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353/4 "2013-11-13T16:01:30Z")

</div>

Hi, Kyle.

One thing to try in your Java code is to call the toString method of the  
top-level QueryBuilder. This creates a pretty-printed JSON string that  
matches the Java query.

Brian

On Monday, November 11, 2013 12:33:12 PM UTC-5, Kyle Pinette wrote:

> For now, I've worked around this by not using the query builders, but by  
> generating the JSON for queries using XContentBuilder.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Kyle\_Pinette](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kyle_pinette/32/1975_2.png) [@Kyle\_Pinette](https://discuss.elastic.co/u/Kyle_Pinette)\
**Post date:** [November 14, 2013, 2:47pm UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353/5 "2013-11-14T14:47:57Z")

</div>

Guys,

I think the error message I posted was not the correct error message, there  
were multiple calls being made and it seems this was an error related to a  
different call.

For now, I've changed my code to generate the queries manually using  
XContentBuilder and this seems to work fine. If I decide to be brave and  
go back to using the QueryBuilders, I'll post a response here.

Thanks,

Kyle

On Wednesday, November 13, 2013 11:01:30 AM UTC-5, InquiringMind wrote:

> Hi, Kyle.
> 
> One thing to try in your Java code is to call the toString method of the  
> top-level QueryBuilder. This creates a pretty-printed JSON string that  
> matches the Java query.
> 
> Brian
> 
> On Monday, November 11, 2013 12:33:12 PM UTC-5, Kyle Pinette wrote:
> 
> > For now, I've worked around this by not using the query builders, but by  
> > generating the JSON for queries using XContentBuilder.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:06am UTC](https://discuss.elastic.co/t/query-run-via-java-api-fails/14353/6 "2017-07-06T02:06:59Z")

</div>


