mongodb ensureIndex parameter

本文涉及的产品
云数据库 MongoDB,独享型 2核8GB
推荐场景:
构建全方位客户视图
简介:
使用方法 : db.collection.ensureIndex({keys : [1|-1|"2d"]},{options : value})


keys

    Field or fields to use as index.
options

    This parameter is an associative array of the form array("optionname" => <boolean>, ...). Currently supported options are:

        *

          "unique"

          Create a unique index.
        *

          "dropDups"

          If a unique index is being created and duplicate values exist, drop all but one duplicate value.
        *

          "background"

          If you are using MongoDB version 1.3.2+, you can create indexes in the background while other operations are taking place. By default, index creation happens synchronously. If you specify TRUE with this option, index creation will be asynchronous.
        *

          "safe"

          Starting with driver version 1.0.4, you can specify a boolean value for checking if the index creation succeeded. The driver will throw a MongoCursorException if index creation failed.

          If you are using replication and the master has changed, using "safe" will make the driver disconnect from the master, throw and exception, and attempt to find a new master on the next operation (your application must decide whether or not to retry the operation on the new master).

          If you do not use "safe" with a replica set and the master changes, there will be no way for the driver to know about the change so it will continuously and silently fail to write.
        *

          "name"

          After driver version 1.0.4 (NOT including 1.0.4) you can specify an index name. This can be useful if you are indexing many keys and Mongo complains about the index name being too long.

使用"2d" 时,
option 还有min和max可选
指定element的取值范围
目录
相关文章
|
12月前
|
SQL 测试技术 数据库
如何设计一个交互式网站?
【10月更文挑战第7天】如何设计一个交互式网站?
276 4
|
关系型数据库 MySQL 网络安全
自建个人音乐播放器Navidrome - 内网穿透实现在外随时访问
自建个人音乐播放器Navidrome - 内网穿透实现在外随时访问
2908 1
|
存储 算法 数据建模
数据结构第6章课后习题答案(下)
数据结构第6章课后习题答案(下)
300 0
|
监控 安全 测试技术
CLAS:用于软件定义网络SDN的协作分层架构
网络软件化的进步正在促进在电信运营商的服务和基础设施中引入可编程性。这通常是通过在网络中引入软件定义网络 (SDN) [RFC7149] [RFC7426] 功能来实现的,包括控制器和协调器。
775 0
CLAS:用于软件定义网络SDN的协作分层架构
|
Linux
树莓派内核驱动编写——添加与调用
树莓派内核驱动编写——添加与调用
591 0
编程小技巧6-在Idea中隐藏指定文件/文件夹
编程小技巧6-在Idea中隐藏指定文件/文件夹
553 0
编程小技巧6-在Idea中隐藏指定文件/文件夹
|
存储 Prometheus 监控
基于Elasticsearch的指标可观测实践
主要介绍Elasticsearch为什么做时序引擎、Elasticsearch做时序引擎的挑战、Elasticsearch 时序引擎特性介绍、阿里云基于Elasticsearch TimeStream介绍。文章结尾更有关于《阿里云Elasticsearch在时序场景下的深入探索》的demo演示视频。
1524 0
基于Elasticsearch的指标可观测实践
|
自动驾驶 安全 物联网
我所理解的loT
lot简称物联网
1118 0
我所理解的loT
|
存储 SQL 搜索推荐
阿里云PostgreSQL精选案例 - 实时精准营销、人群圈选
标签 PostgreSQL , 阿里云 , 实时精准营销 , 人群圈选 , 广告 背景 行业: 几乎所有行业, 如互联网、新零售、教育、游戏等. 应用场景: 根据目标群体的特征, 快速提取目标群体.
2981 0
阿里云PostgreSQL精选案例 - 实时精准营销、人群圈选
|
XML 网络协议 JavaScript
VOIP—软交换系统
Asterisk Asterisk是一个开源的PBX,Ast的模块化架构使得它可以支持sip,h323,iax,dahdi等接口,所以是目前功能最为齐全的PBX平台,而内部处理机制限制了它在高并发量环境的应用。