Я попытался удалить таблицу "guides", перестроить ее и обеспечить индекс для поля "geo", но он все еще не работает. Вот информация и ошибки от pymongo. А также почему индекс всегда возвращает "geo_1"?
>>> db.guides.ensure_index('geo', pymongo.GEO2D)
u'geo_1'
>>> db.guides.index_information()
{u'geo_1': {u'unique': u'2d', u'key': [(u'geo', 1)], u'v': 0}, u'_id_': {u'key': [(u'_id', 1)], u'v': 0}}
>>> db.guides.find_one()['geo']
[61.21572299999999, -149.88431399999999]
>>> db.guides.find_one({ 'geo' : { '$near' : [62.215, -139.884] }})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/collection.py", line 469, in find_one
for result in self.find(spec_or_id, *args, **kwargs).limit(-1):
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 601, in next
if len(self.__data) or self._refresh():
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 564, in _refresh
self.__query_spec(), self.__fields))
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 533, in __send_message
self.__tz_aware)
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/helpers.py", line 100, in _unpack_response
error_object["$err"])
pymongo.errors.OperationFailure: database error: can't find special index: 2d for: { geo: { $near: [ 62.215, -139.884 ] } }
>>> db.guides.drop_index('geo_1')
>>> db.guides.ensure_index('geo', pymongo.GEO2D)
u'geo_1'
>>> db.guides.index_information()
{u'geo_1': {u'unique': u'2d', u'key': [(u'geo', 1)], u'v': 0}, u'_id_': {u'key': [(u'_id', 1)], u'v': 0}}
>>> db.guides.drop_index('geo_1')
>>> db.guides.drop_index('geo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/collection.py", line 757, in drop_index
allowable_errors=["ns not found"])
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/database.py", line 293, in command
msg, allowable_errors)
File "/usr/local/lib/python2.6/dist-packages/pymongo-1.10-py2.6-linux-x86_64.egg/pymongo/helpers.py", line 126, in _check_command_response
raise OperationFailure(msg % response["errmsg"])
pymongo.errors.OperationFailure: command SON([('dropIndexes', u'guides'), ('index', 'geo')]) failed: index not found