hmarr/mongoengine — Issue #331: Multiple GeoPointFields in a single document break
Author: maxcountryman
Created: 2011-10-24 18:49:38+00:00
State: open

For some reason if I defined two or more GeoPointFields in a document, filtering by those fields fails with an error such as:

>>> Place.objects(dest__within_distance=[['47.60620950', '-122.33207080'], 50])
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/mongoengine/queryset.py", line 1615, in __repr__
data = list(self[self._skip:limit])
File "/Library/Python/2.7/site-packages/mongoengine/queryset.py", line 877, in __len__
return self.count()
File "/Library/Python/2.7/site-packages/mongoengine/queryset.py", line 874, in count
return self._cursor.count(with_limit_and_skip=True)
File "/Library/Python/2.7/site-packages/pymongo/cursor.py", line 464, in count
**command)
File "/Library/Python/2.7/site-packages/pymongo/database.py", line 340, in command
msg, allowable_errors)
File "/Library/Python/2.7/site-packages/pymongo/helpers.py", line 126, in _check_command_response
raise OperationFailure(msg % response["errmsg"])
pymongo.errors.OperationFailure: command SON([('count', u'place'), ('query', {'dest': {'$within': {'$center': [['47.60620950', '-122.33207080'], 50]}}, '_types': 'Place'}), ('limit', 21), ('fields', None)]) failed: exception: can't find special index: 2d for: { dest: { $within: { $center: [ [ "47.60620950", "-122.33207080" ], 50 ] } }, _types: "Place" }

While defining only one GeoPointField on the same, otherwise unaltered document, works fine.