How does Algolia count a record?

Let’s say I have 100 authors and for simplicity, each author has written 2 books.

So the root resource (author) has a nested relationship (books).

How many records would Algolia count this as?

100 (the root resource) or 300 (authors + books)?

Hi there,

So if you think about your data and how you plan to use it you could end up with 1 of 2 structures.

If I was going to build an app that was primarily about authors, we’d have 100 records with an authors index and structure like the following:

    "name": "William Shakespeare",
    "books": [{ "title": "A Midsummer nights dream" }]
  { "name": "...", "books": [{ "title": "..." }] },
  { "name": "...", "books": [{ "title": "..." }] }

But, if my app was going to primarily be about books it might make sense to have a books index with a structure of 300 book objects that have an author_name property like so:

    "author_name": "William Shakespeare",
    "title": "A Midsommer nights dream"
  { "author_name": "...", "title": "..." },
  { "author_name": "...", "title": "..." }

There really isn’t a best practice in this case and has to be decided on a case by case basis depending on the data and business use-case.