在另一张 SO 海报(Vinicius Miana)解决了我的问题以插入List[DBObject]
...
// Bulk insert all documents
collection.insert(MongoDBList(docs)) // docs is List[DBObject]
现在,我在尝试插入时看到了这个错误。
java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_id]
编辑
完整的堆栈跟踪
[info] java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_id]
[info] at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:161)
[info] at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:152)
[info] at org.bson.types.BasicBSONList.get(BasicBSONList.java:104)
[info] at com.mongodb.DBCollection.apply(DBCollection.java:767)
[info] at com.mongodb.DBCollection.apply(DBCollection.java:756)
[info] at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:220)
[info] at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:204)
[info] at com.mongodb.DBCollection.insert(DBCollection.java:76)
[info] at com.mongodb.casbah.MongoCollectionBase$class.insert(MongoCollection.scala:508)
[info] at com.mongodb.casbah.MongoCollection.insert(MongoCollection.scala:866)
我已经检查了一篇与我完全相同的问题的帖子,但我不确定如何应用已接受的答案。
此错误是否意味着我无法插入任何value
不可转换为Int
(每个BasicBSONList)的键值对?