Most performant way to query all documents when using a field following the attribute pattern?


Recently been restructuring my data to cope with dynamic fields being added into documents, having a List[Map[String, String]] field following the Attribute Pattern.

Now, how should I do to query the data in here?

I’ve got a couple of cases:

  • To query all the data without caring about myNewField.key and myNewField.value, should I just do {$exists: {myNewField.key: true}} for both key and value?

  • Also, to query by specific keys and values, is an $in performant enough or is there a better way to do so?