Please add a query that will return the "structure" of the document, instead of the data. The structure will allow application to understand the data that is embeded in the document, and then construct a query that will be efficient.
In concept, this is similar to the JDBC meta data query.
Given the schema-less of Mongo, I'm not sure that there is a perfect solution. The basic idea is to summarize the data. In theory, constructing a JSON schema from the data will work, but this is unrealistic approach.
- Replace STRING values with "STRING(N)" (N is size)
- Replace ARRAY with ARRAY of TYPE. If all entries have same type (e.g., number, string) it will be ARRAY[N] of type. Otherwise ARRAY[N] of object.
- Replace BLOB with BLOB(n).
- Replace array of OBJECTS, with ARRAYS of ([ list of available attributes] )
When processing documents from existing repositories when the full structure is unknown, applications are forced to load complete documents, just to find out what data is available.
Having the ability to get (some) meta data, will reduce the amount of data that is loaded by a factor of 100X for our application.