Indexing Data Structure

Hello, I am trying to figure out the best way to structure our data for Algolia search.

We have a note taking app that users can create multiple pages. Each page is made up of blocks that contain the actual text that our users will search for.

Our initial idea was to send each block to Algolia and this is working well, but it is creating a lot of records (as you can have 100+ blocks per page).

[
    {
        "objectID": 1,
        "text": "Table of contents",
        "type": "heading-2",
        "page_id": 1,
        "workspace_id": 1,
    },
    {
        "objectID": 2,
        "text": "Quas saepe quo enim.",
        "type": "list-item",
        "page_id": 1,
        "workspace_id": 1,            
    }
]

What I want to try is to index each page with an array of block objects. This will create larger record sizes but fewer records.

[
    {
        "objectID": 1,
        "title": "My first test document",
        "workspace_id": 1,
        "blocks": [
            {
                "block_id": 1,
                "text": "Table of contents",
                "type": "heading-2"
            },
            {
                "block_id": 2,
                "text": "Quas saepe quo enim.",
                "type": "list-item"
            },
        ]
    }
]

When performing searches, we get the entire page object back, and not just the matching blocks within the page object. Is there a way to do with in Algolia?

Thanks for your help!

HI @king724, To get the blocks back separately, you will need to store the blocks in separate records as you were doing before, as Algolia returns the record in the results.