Unordered_set in MongoDB

I want to create a field like unordered_set (unique elements) in C++. I find 2 ways to do:

  1. list: tags = [“a”, “b”, “c”, …]
  2. embedded document: tags = {“a”: true, “b”: true, “c”: true, …}
    At this time, I don’t care about indexes (multi-key indexes). I want to consider about these operations:
  • Add a element into tags
  • Find a element in tags
    If tags is an array, searching is O(n).
    If tags is an embedded document, does this way have better performance ??