That line in the docs is partially correct, but should be clarified. I’ve notified the docs team.
An array is indexed as a single, scalar value unless marked as a Multi-valued Attribute (MVA) by
(FQL) setting the index’s mva flag to true, or
(FSL) wrapping the term the mva() helper
IMPORTANT: MVA’s only works when the array is the LAST item in the field path. I.e. there is nothing magical about traversing field paths for index terms and values*. It works the same as though querying the field.
Consider here the path .notificationPhoneNumbers.phoneNumberId. This will always resolve to null because .notificationPhoneNumbers is an array, and arrays do not have a phoneNumberId field.
Instead, create a computed field to turn your complex object in to precisely the array you wish to index, and specify the index term as mva
collection TestArrayIndexing {
// every term here resolves to `null` and no entries are created
index byPhoneNumberId {
terms [.notificationPhoneNumbers.phoneNumberId]
}
// use a computed field instead
compute phoneNumberIds = (.notificationPhoneNumbers.map(.phoneNumberId))
index byPhoneNumberId2 {
terms [mva(.phoneNumberIds)]
}
* NOTE: field paths when defining v4 indexes were kinda magic, as they would automatically map over arrays, but in v10 you have to be explicit with the field path.