- Filter on children
- Update parents without affecting children
- Index a tree-like data structure
- Model a one-to-many relationship.
Model relationships in your JSON file
To model a parent-child relationship in the records of your Algolia JSON data:-
Create one record per child,
and add a unique reference to their parent as a key-value pair (
parentID
in the example) - Donβt create records for parents.
Dataset
JSON
Implementation notes
Since this structure doesnβt have parent records, you can only query children. To retrieve the most relevant child per parent (parentID
in the preceding example),
use Algoliaβs distinct feature.
For more information, see: