Lazyexpert
Lazyexpert

Reputation: 3164

Mongo index [String] property

I was just reviewing some code, and saw such property in the mongoose scheme:

names: {
  type: [String],
  index: true
}

As far as I understand how indexes work, they are binary trees, and how is this going to be organized as a node of a tree? Is there at all any sense of indexing such property?

Upvotes: 0

Views: 65

Answers (1)

Treefish Zhang
Treefish Zhang

Reputation: 1161

'If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array.' Per MongoDB documentation on multikey index.

Upvotes: 1

Related Questions