This is a record in mongodb.
{
numbers: [1,2,3,4,5]
}
As title, If I create an indexing in mongo like
{
numbers: 1
}
It will works? Or index works only on single value like number or string type?
Yes, you can and it works:
To index a field that holds an array value, MongoDB creates an index key for each element in the array. These multikey indexes support efficient queries against array fields. Multikey indexes can be constructed over arrays that hold both scalar values 1 (e.g. strings, numbers) and nested documents.
please visit the doc: Mongodb documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With