Can't retrieve 4 levels of nested entities with Algolia

Hello, I am having trouble retrieving nested collections of objects over 3 levels of recursion.

I have the following entity hierarchy:

  • Product
  • ProductFormula ([1 - n] with Product)
  • ProductDuration ([1 - n] with ProductFormula)
  • ProductPricing ([1 - n] with ProductDuration)

I store them all on algolia and they are all effectively stored individually and linked as collections to their parent entities:

  • From the ProductDuration objects I can see a productPricings array of objects
  • From the ProductFormula objects I can see a productDurations array of ProductDuration objects and each of them contains (when existing) an array of productPricings
  • BUT, from the Product object, I see the ProductFormula array, and then the ProductDuration array, but the productPricings is always null.

This was happening in the algolia explorer, so at first I thought that it would be a “preview” limitation. But when I make an actual query from my app (Symfony App, with the symfony bundle from algolia) I get the same problem.

I am trying to find a maxnestinglevel parameter but can’t quite put my hands on it. Did I miss something out ?

Link to the stackoverflow question:

Hi Florent,

Thanks for reaching out!
To further help you, can you give us access to your indices so we can understand the data schema and test things on our side ? You can do that from this page.

I just gave you access. In temporary measure I decided to index arrays built on my side, which works great, but doesn’t feel very nice.

@karim.matrah I just updated my database to reproduce the issue.
I have images & image_entities fields that are equal, so the entity indexing works as good as the “dump an array” field.
But for the formula_entities field, you can see that the field tree does not go as deep as the simple formulas field which basically is several nested array_maps.
So it really feels like the nesting retrieval of entities is limited

Hello @karim.matrah, did you have any time to look up my strange problem ? Thanks a lot!

Hello Florent,

Sorry for the late response… I confirm that we now have access to your indices. Someone from the Lavaral/Symfony support will reach out to you :slight_smile:

Can you try to use fetch="EAGER" in your ProductDuration class? I believe this should force loading the ProductPricing relationships

Another way could be to index a method and load relationships explicitly. Something like:

public function getProductPricing() {
    return $this->getProductFormula()->getProductDuration()->getProductPricing();

I don’t really understand your first method as it seems to me that this is an Algolia-database related problem. I did try putting eager on my php class but this had no effect. As I said, the relationships are actually indexed properly because if I retrieve a ProductFormula I have all the nested durations & pricings. This really is a problem in the max nested level of retrieval from algolia search. Is there a fetch="eager" option for algolia annotations too ?

The second method is precisely what I did until now by doing several nested array_maps…really not ideal & I might hit the size limit. Each entities has a One to Many link to the following so there is no usefulness in retrieving the ProductPricings alone from the Product (see my data hierarchy).

@julienbourdeau do you have any clues as why the entity array is not deep enough ?