0

I want to allow storing documents with a standard set of properties, but also have the ability to add any number of custom properties. Given a filter, I would like to quickly (i.e. not having to iterate through each doc) get a unique/distinct list of those custom properties. Is there a standard/recommended way of getting them or do I have to essentially manually index myself when storing a document?

Nelson Rothermel
  • 9,436
  • 8
  • 62
  • 81
  • @StanleyGong - I don't believe `DISTINCT` will help the OP, as that returns distinct *values* for a property. If I'm reading the question correct, the OP wants distinct *property names*. – David Makogon Dec 14 '20 at 13:27
  • There is no way to get a list of properties in use; you would have to discover (or track) this yourself. – David Makogon Dec 14 '20 at 13:28
  • @ImrePühvel: Your link was useful. Also, this MongoDB answer (https://stackoverflow.com/a/11119091/177333) had an interesting implementation idea: with each document store the field names as values so that you can query them. I'll have to think of the best approach and maybe do some testing, but this gives me a good starting point. – Nelson Rothermel Dec 14 '20 at 22:35
  • @DavidMakogon: You're correct, I was looking for property names, not the values. Thanks for the confirmation that it's not possible. – Nelson Rothermel Dec 14 '20 at 22:35

0 Answers0