# Zero results for Geodistance filter

**URL:** <https://discuss.elastic.co/t/zero-results-for-geodistance-filter/14404>\
**Category:** Elasticsearch\
**Created:** [November 14, 2013, 11:36am UTC](https://discuss.elastic.co/t/zero-results-for-geodistance-filter/14404 "2013-11-14T11:36:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Webber](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Peter\_Webber](https://discuss.elastic.co/u/Peter_Webber)\
**Post date:** [November 14, 2013, 11:36am UTC](https://discuss.elastic.co/t/zero-results-for-geodistance-filter/14404/1 "2013-11-14T11:36:19Z")

</div>

I am using elasticSearch's Java API. What I want to do, is search for posts  
that are around a certain point on in a city. Thus each post has a  
coordinates field. Here's my code to achieve the mapping:

```
String mappingString =
        "{"
        + "\"posts\" : {"
        + "\"properties\" : {"
        + "\"coordinates\" : {"
        + "\"type\" : \"geo_point\""
        + "}"
        + "}"
        + "}"
        +"}";     

```

Client.admin().indices().preparePutMapping("posts").setType("posts").setSource(mappingString).execute().actionGet  
();

And here's the code I use for querying ElasticSearch:

```
GeoDistanceFilterBuilder gdFilter =   

```

FilterBuilders.geoDistanceFilter("posts.coordinates")  
.point(lon, lat)  
.distance(distanceInMeters, DistanceUnit.METERS)  
.optimizeBbox("memory")  
.geoDistance(GeoDistance.ARC);

```
SearchResponse response = Client.prepareSearch("posts")
    .setQuery(QueryBuilders.matchAllQuery())
    .setFilter(gdFilter)
    .setSize(100)
    .execute()
    .actionGet();

```

I verified with ElasticSearch Head that I indeed have posts in the index  
that should pass the filter. But whatever values I use for the variables in  
the query and the filter, I always get zero results. If I comment out  
"setFilter(gdFilter)" I receive results, so the issue should be with the  
filter or the mapping, I guess.

Can someone see, what I am doing wrong?

Many thanks!

--  
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:07am UTC](https://discuss.elastic.co/t/zero-results-for-geodistance-filter/14404/2 "2017-07-06T02:07:02Z")

</div>


