# Mapping and geo-filter

**URL:** https://discuss.elastic.co/t/mapping-and-geo-filter/5043
**Category:** Elasticsearch
**Created:** [August 3, 2011, 12:10pm UTC](https://discuss.elastic.co/t/mapping-and-geo-filter/5043 "2011-08-03T12:10:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)
#### Post date: [August 3, 2011, 12:10pm UTC](https://discuss.elastic.co/t/mapping-and-geo-filter/5043/1 "2011-08-03T12:10:08Z")

</div>

Hi,

I am having a problem with a mapping defining a geo\_point, but no  
ideas anymore where the problem is. Maybe someone can give me a hint.

I am creating a mapping for an index where I want to set a field  
"location" as a geo\_point

```
public static XContentBuilder createGeoMapping (IndexType index)

```

throws IOException {  
return JsonXContent.contentBuilder()  
.startObject()  
.startObject(ElasticSearchIndex.getType(index))  
.startObject("properties")  
.startObject("location")  
.field("type", "geo\_point")  
.endObject()  
.endObject()  
.endObject()  
.endObject();  
}

After applying this mapping to the desired index I insert document  
with a field like "location" : "40.060008,23.461561".

Searching on this index works fine, as soon as I want to add e.g.  
geo\_bbox filter to this query I am getting an exception like  
"org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
to execute phase [query], total failure; shardFailures  
{[KDmzsTNZSLO35OKUl7vc6A][picture][11]: SearchParseException[[picture]  
[11]: query[+PLACE:greece],from[-1],size[100000]: Parse Failure  
[Failed to parse source [_na_]]]; nested:  
QueryParsingException[[picture] failed to find geo\_point field  
[GeoBoundingBoxFilter]]; }"

Can anyone give me a hint on this?

Thanks in advance!  
Andrej

---

<div class="post-metadata">

### Author: ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)
#### Post date: [August 4, 2011, 2:24pm UTC](https://discuss.elastic.co/t/mapping-and-geo-filter/5043/2 "2011-08-04T14:24:44Z")

</div>

Ok, I spent some more time on this, obviously the problem is not the  
mapping, but the added filter. I have a mapping on the index, I can do  
filtered search queries using curl. I tried the following to rebuild  
this using the Java API

1. get a Filter  
public FilterBuilder getGeoBoundingBoxFilter (double bottomRightLon,  
double bottomRightLat, double topLeftLon, double topLeftLat) {  
GeoBoundingBoxFilterBuilder geoBox = new  
GeoBoundingBoxFilterBuilder("GeoBoundingBoxFilter");  
geoBox.bottomRight( bottomRightLat, bottomRightLon);  
geoBox.topLeft(topLeftLat, topLeftLon);  
return geoBox;  
}

2. create a working search request  
SearchRequestBuilder request = ... (runs, delivering wanted  
results)

3. add the filter to the request  
request.setFilter(filter); (Filter is returned from step 1)

4. execute this request  
SearchResponse response = request.execute().actionGet();

The exception is the same as above, stating that no geo\_point can be  
found. Can anyone give me a hint what I am doing wrong or why I can do  
this filtered request with curl but not with the Java API?

---

<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: [August 4, 2011, 7:49pm UTC](https://discuss.elastic.co/t/mapping-and-geo-filter/5043/3 "2011-08-04T19:49:51Z")

</div>

The parameter the GeoBoundingBoxFilterBuilder accepts is the field name, so  
you should pass there "location". A note on using the builder APIs, use  
QueryBuiders/FilterBuilders for static construction method for  
queries/filters. And, you can chain the methods. This should make things  
more readable and people will be less appalled by "that Java code" 🙂

On Thu, Aug 4, 2011 at 5:24 PM, Andrej Rosenheinrich \<  
[andrej.rosenheinrich@unister.de](mailto:andrej.rosenheinrich@unister.de)\> wrote:

> Ok, I spent some more time on this, obviously the problem is not the  
> mapping, but the added filter. I have a mapping on the index, I can do  
> filtered search queries using curl. I tried the following to rebuild  
> this using the Java API
> 
> 1. get a Filter  
> public FilterBuilder getGeoBoundingBoxFilter (double bottomRightLon,  
> double bottomRightLat, double topLeftLon, double topLeftLat) {  
> GeoBoundingBoxFilterBuilder geoBox = new  
> GeoBoundingBoxFilterBuilder("GeoBoundingBoxFilter");  
> geoBox.bottomRight( bottomRightLat, bottomRightLon);  
> geoBox.topLeft(topLeftLat, topLeftLon);  
> return geoBox;  
> }
> 
> 2. create a working search request  
> SearchRequestBuilder request = ... (runs, delivering wanted  
> results)
> 
> 3. add the filter to the request  
> request.setFilter(filter); (Filter is returned from step 1)
> 
> 4. execute this request  
> SearchResponse response = request.execute().actionGet();
> 
> The exception is the same as above, stating that no geo\_point can be  
> found. Can anyone give me a hint what I am doing wrong or why I can do  
> this filtered request with curl but not with the Java API?

---

<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:58am UTC](https://discuss.elastic.co/t/mapping-and-geo-filter/5043/4 "2017-07-06T03:58:14Z")

</div>


