Try our conversational search powered by Generative AI!

Nested Queries with More Than One Level

Vote:
 

We're implementing Find for a client who requires filtering on dynamic attributes at the ProductVariant level. 

IE

  • Product
    • ProductVariant
      • Attributes
        • Color: Brown
        • Material: Wood
    • ProductVariant2
      • Attributes
        • Color: Brown
        • Material: Steel

A possible search would be searching for a Product that has a ProductVariant that has both Attributes with the combination {"Color":"Brown"} and {"Material":"Wood"}. From what I understand, Nested Queries, facets and filters only allow for one additional level and expect to check a property at that level. I've found examples where Dictionaries work, but this would limit us to one key value pair per attribute which I would prefer not to do.

Is there another alternative to this? I've seen others searching for a similar feature set, but haven't found a solution that doesn't limit us to a Dictionary. Searching by ProductVariant and finding distinct Products is not an option.

#180175
Jun 30, 2017 19:11
Vote:
 

It's usually a good approach to setup a property just to facilitate easier search queries. In this case it sounds like the UX is listing product so put a new property there where you iterate all variants and add the values in some useful structure.

#180180
Jul 01, 2017 0:08
Vote:
 

Johan,

Sorry I missed the post over my holiday and just recently started to work on the project again. The client really wants them to be dynamic and control attribute in a central database. They want the ability to add many new attributes at will and not require development when they do so.

My initial plan was to use a dictionary, but this plan is made invalid by finding out yesterday that some productvariants may have multiple values per attribute. This means even properties of IEnumerable wouldn't work either as I don't believe you can build facets from nested objects with IEnumerables.

I understand you're advocating for bringing the properties up to the product level. This wouldn't produce the desired result either as we want to find the product where the productvariant meets the given criteria.

IE The actual structure of the product, productvariants would be:

  • Product
    • ProductVariant
      • Color = Brown
      • Material = Steel
    • ProductVariant2
      • Color = Black
      • Material = Wood

Your suggesting the Find structure would be:

  • Product
    • Colors = {Brown, Black}
    • Materials = {Steel, Wood}

This would result in a hit for {Color = Brown, Material = Wood}, but in reality neither of the productvariants are hits, so the product should not be displayed.

I don't think this is difficult when writing your own search, but I don't believe it's possible with Find as is right now. Some other ideas I have:

  • two requests to Find - one for variants and the other for products, but that sounds slow and will use up extra queries,
  • move ProductVariants up to the Product level, but that is not desired from both a product page or administration point of view,
  • move some properties to the ProductVariant level and search for ProductVariant which links to the Product page.

Do you have any other ideas? Is there any hope to have nested facets work with IEnumerables?

#180804
Jul 26, 2017 17:25
Vote:
 

Hi Michael,

We currently have the exact same dilemma you described.  Wondering if you ever got anywhere with this, or what solution you ultimately went with ?

Thanks!

#187650
Jan 30, 2018 21:13
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.