Searching multiple attributes of nested objects

Hello,

I’d like to use Algolia to search an inventory of around 40,000 rental and hire purchase products. At current pricing, I will not get approval for anything more than the Starter plan, which limits my record count to 100K.

Each product can have many different purchase terms associated with it (often hundreds), but the 100K limit prevents me simply duplicating each record with every possible permutation. I was hoping to model each product like so, with each permutation as a nested object:

{
  "objectID": 1001,
  "sku": "PVN001",
  "name": "Example Product",
  "purchase_options": [                     
    {
      "name": "Rental 36M",
      "contract": "rental",
      "term": 36,
      "monthly_price": 17.65,
      "total_price": 635.4,
    },
    {
      "name": "Rental 24M",
      "contract": "rental",
      "term": 36,
      "monthly_price": 26.48,
      "total_price": 635.4,
    },
    {
      "name": "HP 48M",
      "contract": "hp",
      "term": 48,
      "monthly_price": 16.67,
      "total_price": 800
    }
  ]
}

A common use case is a customer searching for a product based on purchase terms (“rental over 36 months, monthly price between £10 - £20”).

Having read the documentation, I am unclear on how I should set up a search that implements this use case using the schema above. How do I specify that the nested object attributes below all apply to the same nested object?

  • purchase_options.contract = rental
  • purchase_options.term = 36
  • purchase_options.monthly_price >= 10
  • purchase_options.monthly_price <= 20

Thanks!

Hi baklava!

From what I understand, it looks like you actually set up your record correctly to be able to search into and facet on these nested objects. If you’d like to search for the actual text, simply designate “purchase_options.contract” and the other attributes as “Searchable Attributes” in the dashboard or via our API. If you’d like to be able to facet on them (search specific term which basically means filter), designate “purchase_options.contract” and the rest of the attributes as “Attributes for faceting” on the “Display” tab of our dashboard or via our API.

I hope that make sense!

Hi Baklava,

Was wondering whether you figured out a solution to your problem. I’m facing kinda’ the same issue at the moment.

Thanks!

Hi Baklava, we have the same issue, have you found a solution on filtering by multiple attributes from the same nested record?

David, together with the awesome support guys @ Algolia , we booked some progress on this.

Unfortunately, we bumped into a little issue in the react Instantsearch component. Check out this issue -> https://github.com/algolia/react-instantsearch/issues/630.

Update: The aforementioned bug has been solved by the Algolia team. This solution now works great!

Would you be willing to share your solution? I have a pretty similar use case. Thanks!

1 Like

+1
I have exactly the same issue. Could you share your implementation please? :pray:
What is the query you made?

I’m so sorry for replying this late. I do not follow this forum on a daily basis.


An example of this can be found on https://codesandbox.io/s/ojxzzoky55

A component wrapped in connectRange does take “attributeName” as a prop.

If you then wrap this component in another component itself wrapped with connectCurrentRefinement like in the example then you can theoretically change the ConnectedRange’s attributeName prop based on current facet refinement values.

In the example, this happens when selecting the “Movies & TV shows” value in the dropdown.