duanke0178 2010-11-19 19:26
浏览 76

MongoDB:ensureIndex不能同时处理单键和复合键

From hours I'm trying to add bulk data in my locally setup MongoDB collection, all is set except unique index for a key or keys :(

I've used this:

ensureIndex({appid:1, userid:1}, {unique:true, dropDups:true, background:true})

then this (coz I guess for whatever reason, multiple keys index is not working)

ensureIndex({userid:1}, {unique:true, dropDups:true, background:true})

after using above lines I tried to insert millions of rows from a php script (via both insert and batchInsert) and everytime duplicate userids are there :'( please please guide me on this :(

  • 写回答

2条回答 默认 最新

  • dongqiangse6623 2010-11-20 19:04
    关注

    It is probably a good idea to look and make sure the index was created. By default write operations (like creating indexes) are fire-and-forget and don't wait for error/success. This could be a bug in the driver (php client lib).

    You can run

    db.coll.getIndexes()
    

    to list the indexes for the collection.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算