Creating and using nested attributes
Learn about nested attributes, and when to use them.
With nested attributes, you can add subcategories to your attributes.
For example, instead of having a single attribute price
, you might set up different prices as subcategories: price.net
, price.gross
, price.margin
.
Use ‘dot notation’ to separate the parent attribute from its child.
How to create nested attributes
You can create nested attributes by adding a JSON object to your records when you send them to Algolia. For example:
An example of filtering nested attributes with an API client
An example of filtering nested attributes with the Algolia CLI
Where you can use nested attributes
You can use nested attributes wherever you might use a regular attribute, such as searchableAttributes
and attributesForFaceting
.
Just make sure you use the appropriate dot notation such as price.country
to refer to them.
There’s no limit on the number of nested attributes apart from the default restrictions on record size.
The depth of nesting is also unlimited: you could use something like price.net.us.ca
.
Was this page helpful?