Ensureindex on array

In my collection I have an array like with exactly two values [a, b]

I want to create unique index on this array so that these excat two values will not repeat again.

For normal fields I can do something like this

User._ensureIndex('user_id', {unique: 1});

but when I try the same for array property it is showing error? Any help?

I’m creating index so that when I query using $in: [val1, val2] it will be fast or am I wrong that $in doesn’t support index?