mongoDB索引结构

I have put Index on mongoDB.

when I ensureIndex using php it put 1 as NumberLong(1) .

I want to know:

  1. will this Indexing work or not. If not
  2. how to remove this NumberLong(1)

Code:

"0": {
    "v" : 1,
    "key" : {
        "telNum" : NumberLong(1),
        "requestID" : NumberLong(1)
    },
    "ns" : "database.collections",
    "background" : true,
    "name" : "tel_req"
  }

Yes, the index will still work.

This is due to a change in the way that the PHP driver works ( https://jira.mongodb.org/browse/PHP-955 ).

I will come out immediately and say that it is not advised to remove it. That NumberLong object supports throwing in 64bit integers by default so it is extremely useful to have the defaults in the new PHP driver on by default and to treat NumberLong as the new generic number object.

However, to go into this a bit more and explain to you what's happening, there is this runtime configuration option called native_long: http://www.php.net/manual/en/mongo.configuration.php#ini.mongo.native-long which essentially allows MongoDB to store 64bit numbers by storing them into NumberLong objects. In PHP it would automatically convert to int data type and back again, making this transparent to the end user.

If you have this turned off MongoDB can only store 32bit integers.

This option used to be off by default but now it is on, that is why you are seeing this behaviour.

You can turn it off in the PHP configuration to remove the NumberLongs