In Algolia records, array elements must be accessed using index-based square bracket notation, not dot notation.
In most programming languages, dot notation is used to access properties of an object. However, dot notation isn’t supported for accessing elements inside arrays in Algolia records.
Instead, you must reference array elements by their index using square brackets.
For example, in the following record, variants is an array:
{
"objectID": "1",
"product": "T-Shirt",
"variants": [
{
"size": "Small",
"color": "Red"
},
{
"size": "Large",
"color": "Blue"
}
]
}To access the value size: "Small", you must use the array index:
variants[0].sizeAccessing array elements with dot notation alone, such as variants.size, isn’t supported in Algolia.
For a more detailed explanation and additional examples, see the related article.