This query targets a more specific position within the array using dot notation ("pathArrayMulti.0" ). This allows MongoDB to directly access and match the first element of the pathArrayMulti array, without the need for multiple levels of $elemMatch. However, the index will not be used either.
Thanks both of you for the query syntax fixes
I now get the data but my biggest issue still remain.
When this collection grows to million of documents it will be to slow without an index.
So is there any way to index or query this 2 dim array so the index is used?
Not that I’m aware of, you may need to re-factor the data to store it in an indexable layout
Not hitting an index is a bit of deal breaker, as you say when data grows to reasonable levels you don’t want to have collection scans all over the palce.
This method overrides MongoDB’s default index selection and query optimization process. It forces MongoDB to use the specified index when performing the query.
You are right, @steevej!
I did mention it in my response:
This query targets a more specific position within the array using dot notation ("pathArrayMulti.0" ). This allows MongoDB to directly access and match the first element of the pathArrayMulti array