-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Point must only contain numeric elements
when using near count query with GeoJson points
#4004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for reaching out could you please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
Sure, I have created a quick example that executes a count with a near query and GeoJSON point in an application runner directly after startup. Just make sure, that you have a MongoDB running locally on port 27017. |
Thanks for the reproducer - the rewrite of |
Related to: #2925 |
Point must only contain numeric elements
when using near count query with GeoJson points
$near and $nearSphere queries are not supported via countDocuments and the used aggregation match stage and need to be rewritten to $geoWithin. The existing logic did not cover usage of geoJson types, which is fixed now. In case of nearSphere it is also required to convert the $maxDistance argument (given in meters for geoJson) to radians which is used by $geoWithin $centerSphere. Closes #4004 Original pull request: #4006. Related to #2925
Count queries using
$near
or$nearSphere
require a rewrite to$geoWithin
. However, according to the official MongoDB documenatation, the syntax for a$near
query is different when using a GeoJSON point instead of legacy coordinates.When creating the
$geoWithin
inCountQuery.createGeoWithin
in combination with a GeoJSON point, the$maxDistance
cannot be found, as it is nested inside the$near
document. With the current implementation,$maxDistance
is only detected if it is on the source level (which is the case when legacy coordinates are used):This results in
maxDistance
having the valueDouble.MAX_VALUE
(which is 1.7976931348623157E308). When executing the rewritten query against MongoDB, this fails with the errororg.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 2 (BadValue): 'Point must only contain numeric elements' on server localhost:27017
, as it cannot handle the scientific notation (1.7976931348623157E308) ofDouble.MAX_VALUE
.Could someone help with that issue?
The text was updated successfully, but these errors were encountered: