索引属性 name指定
- db.collection.ensureIndex({param},{param})
- 名字
- db.collection.ensureIndex({},{name:''})
- 在创建索引时,mongodb会自己给索引创建默认的名字,这种名字并不好记,我们看一下mongodb是怎么给自己命名的
- 唯一性
- 稀疏性
- 是否定时删除:比如过期索引
- > db.suoyin.getIndexes()
- [
- {
- "v" : ,
- "key" : {
- "_id" :
- },
- "name" : "_id_",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" :
- },
- "name" : "x_1",
- "ns" : "test.suoyin"
- }
- ]
- > db.suoyin.getIndexes()
- [
- {
- "v" : ,
- "key" : {
- "_id" :
- },
- "name" : "_id_",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" :
- },
- "name" : "x_1",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "y" : -
- },
- "name" : "y_-1",
- "ns" : "test.suoyin"
- }
- ]
- > db.suoyin.ensureIndex({x:,y:-})
- > db.suoyin.getIndexes()
- [
- {
- "v" : ,
- "key" : {
- "_id" :
- },
- "name" : "_id_",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" :
- },
- "name" : "x_1",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "y" : -
- },
- "name" : "y_-1",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" : ,
- "y" : -
- },
- "name" : "x_1_y_-1",
- "ns" : "test.suoyin"
- }
- ]
- > db.suoyin.ensureIndex({x:,y:,z:,m:},{name:'normal_index'})
- {
- "createdCollectionAutomatically" : false,
- "numIndexesBefore" : ,
- "numIndexesAfter" : ,
- "ok" :
- }
- > db.suoyin.getIndexes()
- [
- {
- "v" : ,
- "key" : {
- "_id" :
- },
- "name" : "_id_",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" :
- },
- "name" : "x_1",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "y" : -
- },
- "name" : "y_-1",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" : ,
- "y" : -
- },
- "name" : "x_1_y_-1",
- "ns" : "test.suoyin"
- },
- {
- "v" : ,
- "key" : {
- "x" : ,
- "y" : ,
- "z" : ,
- "m" :
- },
- "name" : "normal_index",
- "ns" : "test.suoyin"
- }
- ]
- > db.suoyin.dropIndex('normal_index')
- { "nIndexesWas" : , "ok" : }
- > db.suoyin.getIndexes()
- [
- {
- "v" : ,
- "key" : {
- "_id" :
- },
- "name" : "_id_",
- "ns" : "test.suoyin"
- }
- ]
索引属性 name指定的更多相关文章
- 索引属性 unique指定
比较重要的属性有: 名字 db.collection.ensureIndex({},{name:''}) 在创建索引时,mongodb会自己给索引创建默认的名字,这种名字并不好记,我们看一下mongo ...
- 攻城狮在路上(壹) Hibernate(三)--- 属性访问、命名策略、派生属性、指定包名等
一.hibernate访问持久化类属性的策略: 在<property>元素中的access属性用于指定Hibernate访问持久化类属性的方式. 常见的方式如下: 1.property:默 ...
- box-sizing属性(指定针对元素的宽度与高度的计算方法)
在css中,使用width属性与height属性来指定元素的宽度与高度.使用box-sizing属性,可以指定用width属性与height属性分别指定的宽度值与高度值是否包含元素的内部补白区域与边框 ...
- 利用pandas选取某个属性符合指定条件的所有行
最近遇到利用pandas选取指定行的需求,经常忘记,在此做下记录 选取某个属性等于特定值的所有行记录 df[(df[‘column_name’] == target_value)] 注:等于用 '== ...
- arcpy显示指定表的索引属性
import arcpy feature_class = "c:/data/well.shp" # Create a list of indexes using the ListI ...
- Spring对外部属性文件指定的某个属性进行加密、解密
[From] http://blog.csdn.net/ethanq/article/details/7333897 在我们开发当中,经常会用到spring框架来读取属性文件的属性值,然后使用占位符引 ...
- html -- contenteditable 属性:指定元素内容是否可编辑
所有主流浏览器都支持 contenteditable 属性 定义和用法 contenteditable 属性指定元素内容是否可编辑. 注意: 当元素中没有设置 contenteditable 属性时, ...
- Java属性中指定Json的属性名称
只需要使用注解"@JsonProperty(value = "pwd")" import com.fasterxml.jackson.annotation.Js ...
- 正则去除html标签属性保留指定标签
/// <summary> /// 去除标签里面的属性保留IMG标签属性 /// </summary> /// <param name="strText&quo ...
随机推荐
- linux网络配置详解
一:相关网络配置的文件 1.网卡名配置相关文件 网卡名命名规则文件: /etc/udev/rules.d/70-persistent-net.rules # PCI device 0x8086:0x1 ...
- 黑匣子_NOI导刊2010提高(06) Splay Tree
题目描述 Black Box是一种原始的数据库.它可以储存一个整数数组,还有一个特别的变量i.最开始的时候Black Box是空的.而i等于0.这个Black Box要处理一串命令. 命令只有两种: ...
- 怎么在Vue中使用Base64格式的背景
问题发生于一次mock数据,生成了base64格式的东西,因为编码包在一个变量中,不知道怎么直接在 :style 中引入. 解答1:格式background-image: url(此处是我们mock生 ...
- 牛客练习赛41D(思维转化)
AC通道 要点 思路:题解中将所求进行转化\[max\{相似度\} = max\{M-不相似度\} = M-min\{不相似度\}\]因此转化为求某01串T与所给众S串的最小不相似度,而最终答案是选取 ...
- Helvetic Coding Contest 2016 online mirror B1
Description The zombies are gathering in their secret lair! Heidi will strike hard to destroy them o ...
- DateAdapterForDay
public class DateAdapterForDay extends XmlAdapter<String, Date> { private SimpleDateFormat dat ...
- 15-----jQuery补充
jquery除了咱们上面讲解的常用知识点之外,还有jquery 插件.jqueryUI知识点 jqueryUI 官网: https://jqueryui.com/ jqueryUI 中文网: http ...
- CentOS 7: ping Name or service not known
解决方法 cd到/etc/sysconfig/network-scripts/ 修改ifcfg-*(*代表的内容可通过ifconfig查看)中的ONBOOT=yes reboot ifcfg-ens3 ...
- 机器学习读书会的分享 - Reinforcement Learning: An Introduction 第4-6章
我在机器学习读书会的分享slides,关于DP.MC.TD方法: https://mp.weixin.qq.com/s/r8wZw4iZwFCz0nnakutY3Q 内容如下:
- 如何远程连接非默认端口SQL Server
SQL Server Management Studio建立远程SQL连接 连接的时候写: 127.0.0.1,49685\sqlexpress 记得使用逗号,不是冒号