Parent Child Rule Help

Hi There,

Apologies for the stupid questions (if they are stupid).

Just getting to grips with Algolia and I like what I see so far.

I have a simple thing I’m trying to do.

So I have 2 indicies, merchants (a list of people selling products) and a products index.

Inside the product index, I make reference to the object ID of the corresponding parent merchant record.

The Product Record

{      "name": "test product",
      "description": "test",
      "productImage": "https://domain.com/assets/img/placeholder.png",
      "price": "1.00",
      "category": "test",
      "is_available": true,
      "vendor": "TEST",
      "vendorID": "vend-217",
      "objectID": "prod-3774",
}

The merchant Record

{
      "is_online": 0,
      "is_genuine_jersey": 0,
      "categories": [
        "Health & Wellness"
      ],
      "name": "TEST",
      "objectID": "vend-217",
}

I am basically looking to apply a rule to my search that says do not display any products that belong to merchants that have the is_online field at 0.

Can anyone help me or advise me on how to do this, or am i totally structuring the data wrong here?

Hey Robert, and welcome!

The trap here is treating your Algolia indices like a relational database. You need to think of each index as a flat, self-contained set of key value pairs. There aren’t concepts like foreign keys or unions when the engine is performing searches.

As you build an index, you want to make sure that all attributes needed to search, filter, and rank those records is contained within that index, even if it duplicates data in other indices.

You can read more about strategies for building well-formed indices and records here:

Hi There,

Thanks for resolving. I modified our sync / import script to add the field for parent records online status to the child record and made the rule filter the false ones out. that did the trick!

Thanks,
Rob

1 Like