0

I not asking how to view the indexes on a collection but how can I look inside the index and see its values?

I have a field that should be unique so I created a unique index and now I want to cross verify that all the documents are present in the index.

Gabriel Fair
  • 4,081
  • 5
  • 33
  • 54

1 Answers1

1

Normally you cannot look inside the index. It's just linked list. But... You can do count from index. db.data.find({},{"_id":1}).hint({"_id":1}).itcount()

In that example I project only field _id, with hint() I ordered system use unique index of "_id" and with itcount() I ordered NOT to use metadata information of count, but go thru that find cursor and do count of every item.

JJussi
  • 1,540
  • 12
  • 12