显示mongodb索引内容 [英] Display mongodb index contents

查看:86
本文介绍了显示mongodb索引内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建索引后,我想查看索引的内容。以MonboDB文档为例进行说明:

After building an index, I'd like to view the contents of the index. Taking an example for illustration from the MonboDB docs:

{ "_id" : ObjectId("..."),
"name" : "Warm Weather",
"author" : "Steve",
"tags" : [ "weather", "hot", "record", "april" ] }

然后标签字段上的索引将具有以下值:

Then an index on the tags field would have these values:

{ tags: "weather" }
{ tags: "hot" }
{ tags: "record" }
{ tags: "april" }

所以,我想运行一个命令,比如说, db.weather._tags_.find()显示所述值。

So, I want to run a command, say, db.weather._tags_.find() to display said values.

问题:是否有这样的shell命令存在?或者有没有办法在C ++驱动程序中执行此操作?

Question: Does such a shell command exist? Or is there a way to do this in the C++ driver?

推荐答案

@ user1883451

@user1883451

你给出的例子是哈希索引,mongodb在内部存储B-Tree索引。

What you have given example is of hash index, mongodb internally stores B-Tree index.

所以你给出的例子并不总是正确的,mongodb结束在某些情况下以这种方式存储,但并非总是如此。 [可以用过于简单的方式理解它]

so example you have given is not always correct, mongodb end-up storing in that way in some case, but not always. [It is fine to understand it in oversimplified way]


  1. shell是客户端,并且它没有显示内部如何存储索引

  2. 驱动程序主要是与服务器交互(过度简化),它也不知道存储内容的方式。

A)如何查看mongodb索引

A)how to view mongodb index

最好的开始是获取mongo源代码并开始玩它。

Best start is to take mongo source code and start playing with it.

https://github.com/带索引的mongodb / mongo / tree / master / src / mongo / db / 文件*
https://github.com/mongodb/mongo/tree/master/src/mongo/db/ 文件与btree *

https://github.com/mongodb/mongo/tree/master/src/mongo/db/ files with index* https://github.com/mongodb/mongo/tree/master/src/mongo/db/ files with btree*

B)我假设你只是为了学习目的而努力。如果您有任何特定查询,为什么要这样做才能查出查询。

B)i assume you are trying to do just for learning purpose. If you are having any specific query, why you want to do that shoot out the query.

PS:
1.有更多代码和更少的文档内部和源代码。
2.您可以加入 http://groups.google.com/group/mongodb-开发

这篇关于显示mongodb索引内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆