An error occurred while trying to provide an index on the built-in field (the key name should not contain ".")

We have been using the mongodb / nodejs driver for several years and are currently updating our systems with the latest driver / mongodb database. Basically, everything went well, except for the indices.

We get an error when trying to use a function collection.ensureIndexto add indexes. This is my first question, so I will try to be as detailed as possible. I did not find a related problem ...

Here are our current versions:

  • Node: v0.10.33
  • Mongodb driver: v2.0.5
  • Mongodb Database: v2.4.12

Here is a test case:

var MongoClient = require('mongodb').MongoClient,
  test = require('assert');
MongoClient.connect('mongodb://localhost:28888/test', function(err, db) {
  var collection = db.collection('ensureIndexEmbedded');
  // Create an index on the a field
  collection.ensureIndex( {"a.c":1}
    , {background:true, w:1}, function(err, indexName) {
      console.log(err);
      //test.equal(null,err);
      db.close();
  });
});

And the test run result:

$ node testindex.js
js-bson: Failed to load c++ bson extension, using pure JS version
{ [MongoError: n/a]
  name: 'MongoError',
  message: 'n/a',
  ok: 1,
  n: 1,
  code: 14,
  errmsg: 'key a.c must not contain \'.\'',
  writeErrors: [ { index: 0, code: 14, errmsg: 'key a.c must not contain \'.\'' } ] }

Is there a chance the warning js-bson: Failed to load c++ bson extensionis related to this problem? Or is there something wrong with the syntax used to create the index?

!

+4
3

- . , . , . . "" functionIndex, .

+1

, mongojs v2.4.0 mongod v3.2.1.

, , . . {"unique" : true}. , , :

  • ( )
  • ,
+1

MongoDB 2.6.5, . , 2.0.5 MongoDB 2.4.12

0

All Articles