文本索引版本

文本索引有以下版本:

文本索引版本 描述
版本3 MongoDB 3.2 引入了文本索引的版本 3。版本 3 是在 MongoDB 3.2 及更高版本中创建的文本索引的默认版本。
版本2 MongoDB 2.6 引入了文本索引的版本 2。版本 2 是 MongoDB 2.6 到 3.0 中创建的文本索引的默认版本。
版本1 MongoDB 2.4 引入了文本索引的版本 1。MongoDB 2.4 仅支持版本 1。

更改索引版本

重要的

尽可能始终使用默认索引版本。仅在出于兼容性原因需要时才覆盖默认版本。

要覆盖默认版本并为文本索引指定不同版本,请textIndexVersion在创建索引时设置该选项:

db.<collection>.createIndex(
   { <field>: "text" },
   { "textIndexVersion": <version> }
)

例子

以下命令在content 字段上创建版本 2 文本索引:

db.test.createIndex(
   { "content": "text" },
   { "textIndexVersion": 2 }
 )
Copyright © 上海锦木信息技术有限公司 all right reserved,powered by Gitbook文件修订时间: 2023-09-01 17:10:26

results matching ""

    No results matching ""