Looks like user is your type, and location is defined on the same level as name or id, so your query should be:
{
"query": {
"bool": {
"must_not": {
"term": {
"id": 2
}
},
"should": {
"match_all": {}
}
}
},
"sort": [{
"_geo_distance": {
"location": [{
"lat": 49.2827291,
"lon": -123.12073750000002
}],
"unit": "km"
}
}]
}
At least thats working for me. Java API or not doesn't make a difference, in 2.3.3 the QueryBuilder and SortBuilder render out Json that is parsed again on the coordinating node, so there is nothing special about the java part that makes it different from going thorugh the REST api.