2013. 1. 31. 17:26

[MongoDB] 2D Geospatial 인덱스 관련 버그 can't find special index: 2d for

출처: https://jira.mongodb.org/browse/SERVER-4572


can't find special index: 2d for:

만약 위와 같은 에러가 발생했다면,

When you got this error,


1 아래의 명령어를 몽고디비 쉘에서 실행하여 2D 인덱스가 생성되었는지 확인하세요
Execute following command on mongodb shell (mongo.exe) to check if 2d index is created

db.collection.getIndexes()


[{"v":1, "key": {"loc": "2d"}, "ns": ..., "name": ...}]

loc 은 이 예시를 위한 프로퍼티 이름으로 다를 수 있습니다.

loc is just property name for this example. it may be different; doesn't matter.


db.collection.get명령어의 결과가 위와 같다면, 몽고디비 쉘에서 아래의 명령어를 실행하여 2D 인덱스를 생성하세요.

If the shell does not show document like this, just execute following command on the shell to create 2D index.

db.collection.ensureIndex({loc: "2d"})


2 쿼리를 살펴보세요 

Take a look the query


2D 인덱스가 생성되었는데도 "can't find special index: 2d for" 에러가 발생하면,

Do you still got the error "can't find special index: 2d for:" even if 2d index is already created? 


{$and: [{...}, {$near: {...}}]}

{$or: [{...}, {$in: {...}}]}

위와 같이 $and 나 $or 안에 2D geospatial 연산자가 있는 쿼리가 있는지 확인하세요

Take a look the query if 2d geospatial operators - $near, $centerSphere, $within - are located in $and/$or criteria 


버전이 2.0.2 에서 2.2.2 사이의 MongoDB 는 이런 쿼리를 실행하면 "can't find special index: 2d for" 에러를 발생하는 버그가 있습니다.

유일한 해결책은 이런 쿼리를 피하는 것입니다.

MongoDB, the version between 2.0.2 and 2.2.2, has the problem that causes "can't find special index: 2d for" error when executing this kind of query.

Please avoid it.







'DB > MongoDB' 카테고리의 다른 글

[MongoDB] Aggregation Framework  (0) 2013.01.04