Is it possible to create a mongodb index on subdocuments keys which can be different in each document? For instance if we have
{
_id: 1,
languages: {
en: {...},
fr: {...},
de: {...}
}
},
{
_id: 2,
languages: {
cs: {...},
fr: {...}
}
}
... to create and index on the languages' keys so later in the find() just to check if this language exists(something like "languages.fr": {$exists: true}).
I suppose this should be similar to creating an index on array field if the languages were an array:
{ _id: 1, languages: ['en', 'fr', 'de']},
{ _id: 2, languages: ['cs', 'fr']}
db.coll.createIndex( { languages: 1 } )