I have this object
{
"sales": [
[
{
"id": "123"
}
]
]
}
May i add an index on the "id" field? How?
I have this object
{
"sales": [
[
{
"id": "123"
}
]
]
}
May i add an index on the "id" field? How?
Copyright © 2021 Jogjafile Inc.
Firstly, This case is about "indexing nested arrays". One minor observation is that the outer array does not have a key. Is it intentional ? If intentional, is there any chance of reviewing the schema. The following 2 points would provide more about it.
Secondly, the above schema means x is a nested array of the array "sales". Is this the kind of schema you are looking for ?. If so, a compound index "sales.x.id" would normally be supported.
Thirdly, you may be able to see a similar case handled in the following link. MongoDB query optimisation for nested array of objects
Thank you WeDoTheBest4You