mongoDB索引结构

我已将索引放在mongoDB上。</ p>

当我使用php确保使用它时,它 将1设为 NumberLong(1)</ strong>。</ p>

我想知道:</ p>


  1. 此索引 是不是</ li>
  2. 如何删除 NumberLong(1)</ strong> </ li>
    </ ol>

    代码: </ p>

     “0”:{
    “v”:1,
    “key”:{
    “telNum”:NumberLong(1),
    “”requestID“ :NumberLong(1)
    },
    “ns”:“database.collections”,
    “background”:true,
    “name”:“tel_req”
    }
    </ code> </ pre >
    </ div>

展开原文

原文

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"
  }

1个回答



是的,索引仍然有效。</ p>

这是由于方式的改变 PHP驱动程序的工作原理( https://jira.mongodb.org/browse/PHP-955</ a>)。</ p>

我会立即出来并说不建议将其删除。 NumberLong </ code>对象默认支持抛出64位整数,因此默认情况下启用新PHP驱动程序中的默认值并将 NumberLong </ code>视为新的通用编号非常有用 对象。</ p>

但是,为了更多地介绍这一点并向您解释发生了什么,有一个名为 native_long </ code>的运行时配置选项: http://www.php.net/manual/en/mongo。 configuration.php#ini.mongo.native-long 基本上允许MongoDB通过将它们存储到 NumberLong </ code>对象中来存储64位数字。 在PHP中,它会自动转换为 int </ code>数据类型并再次返回,使其对最终用户透明。</ p>

如果关闭此项,MongoDB只能存储 32位整数。</ p>

此选项默认情况下已关闭但现在已启用,这就是您看到此行为的原因。</ p>

您可以 在PHP配置中将其关闭以删除 NumberLong </ code> s </ p>
</ div>

展开原文

原文

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐