Zero results for Geodistance filter

(Peter Webber) #1

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\""
        +            "}"
        +        "}"
        +    "}"


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

GeoDistanceFilterBuilder gdFilter =   

.point(lon, lat)
.distance(distanceInMeters, DistanceUnit.METERS)

SearchResponse response = Client.prepareSearch("posts")

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
For more options, visit

(system) #2