# Java API-GeoDistanceFilterBuilder not working as desired \[Some issue with generated square brackets\]

**URL:** <https://discuss.elastic.co/t/java-api-geodistancefilterbuilder-not-working-as-desired-some-issue-with-generated-square-brackets/10597>\
**Category:** Elasticsearch\
**Created:** [February 1, 2013, 9:01pm UTC](https://discuss.elastic.co/t/java-api-geodistancefilterbuilder-not-working-as-desired-some-issue-with-generated-square-brackets/10597 "2013-02-01T21:01:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_2](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@john\_2](https://discuss.elastic.co/u/john_2)\
**Post date:** [February 1, 2013, 9:01pm UTC](https://discuss.elastic.co/t/java-api-geodistancefilterbuilder-not-working-as-desired-some-issue-with-generated-square-brackets/10597/1 "2013-02-01T21:01:23Z")

</div>

Hi,

I'm getting issues with the GeoDistanceFilterBuilder. Below is the Java API  
code that create a GeoDistanceFilterBuilder.  
fb = new  
GeoDistanceFilterBuilder("X.location").lon(Double.valueOf(longitude)).lat(Double.valueOf(lattitude)).distance(Double.valueOf(distance),  
DistanceUnit.MILES);

and this filter is appended to a match all query to finally get the below  
query.  
{  
"from" : 0,  
"size" : 10,  
"query" : {  
"bool" : {  
"must" : {  
"filtered" : {  
"query" : {  
"match\_all" : {  
}  
},  
"filter" : {  
"geo\_distance" : {  
"X.location" : [44.824971, -93.316218],  
"distance" : "15.0mi"  
}  
}  
}  
}  
}  
}  
}

However this does work but if i replace the Square brackets around the  
long/lat to quotes it does.Below is the working query.  
{  
"from" : 0,  
"size" : 10,  
"query" : {  
"bool" : {  
"must" : {  
"filtered" : {  
"query" : {  
"match\_all" : {  
}  
},  
"filter" : {  
"geo\_distance" : {  
"X.location" : "44.824971, -93.316218",  
"distance" : "15.0mi"  
}  
}  
}  
}  
}  
}  
}

Can someone pls explain why its behaving like this?

Thanks,  
John

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2013, 9:57pm UTC](https://discuss.elastic.co/t/java-api-geodistancefilterbuilder-not-working-as-desired-some-issue-with-generated-square-brackets/10597/2 "2013-02-01T21:57:05Z")

</div>

## When using arrays, the format is [lon, lat]. See: [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html)

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 févr. 2013 à 22:01, john [john2roll2@gmail.com](mailto:john2roll2@gmail.com) a écrit :

> Hi,
> 
> I'm getting issues with the GeoDistanceFilterBuilder. Below is the Java API code that create a GeoDistanceFilterBuilder.  
> fb = new GeoDistanceFilterBuilder("X.location").lon(Double.valueOf(longitude)).lat(Double.valueOf(lattitude)).distance(Double.valueOf(distance), DistanceUnit.MILES);
> 
> and this filter is appended to a match all query to finally get the below query.  
> {  
> "from" : 0,  
> "size" : 10,  
> "query" : {  
> "bool" : {  
> "must" : {  
> "filtered" : {  
> "query" : {  
> "match\_all" : {  
> }  
> },  
> "filter" : {  
> "geo\_distance" : {  
> "X.location" : [44.824971, -93.316218],  
> "distance" : "15.0mi"  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> However this does work but if i replace the Square brackets around the long/lat to quotes it does.Below is the working query.  
> {  
> "from" : 0,  
> "size" : 10,  
> "query" : {  
> "bool" : {  
> "must" : {  
> "filtered" : {  
> "query" : {  
> "match\_all" : {  
> }  
> },  
> "filter" : {  
> "geo\_distance" : {  
> "X.location" : "44.824971, -93.316218",  
> "distance" : "15.0mi"  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> Can someone pls explain why its behaving like this?
> 
> ## Thanks, John
> 
> 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).

--  
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:53am UTC](https://discuss.elastic.co/t/java-api-geodistancefilterbuilder-not-working-as-desired-some-issue-with-generated-square-brackets/10597/3 "2017-07-06T02:53:28Z")

</div>


