简体   繁体   中英

Mongodb ensureIndex

I am working on Mongodb where I am trying to do the indexing on my collection, it is taking only the range between -140 to 3320000 then the total indexing is coming very high ie 23628640 (By using db.Location.totalIndexSize() )

Because of that my query is taking more time in execution.

How can I make the indexing between (-180 ,180)? please help me out

db.Location.ensureIndex({loc:"2d",type:1,clientId:1,background:true},{min:-140,max:3320000})

I think your syntax is wrong. You probably want:

db.Location.ensureIndex({loc:"2d",type:1,clientId:1}, {background:true})

The min and max options are optional and default to -180 and 180. Do you have any objects that fall outside of that range? It would be helpful to see the error you get and an example object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM