Searching with subdocuments (children or nested or smth else)?


(ddorian43) #1

Hi !,

I have an ecommerce-search I'm building. My problem, is that some products have ALOT of subproducts. Let me explain. The products are clothes. On the clothes I have "Levy jeans Blue" "Levy jeans white" "Levy jeans green", "Levy jeans black", "Levy jeans red" . By my count, only 5% of the products have different variants.

What I want, is that when you search "Levy jeans" only 1 product shows from the whole collection of "Levy jeans" (doesn't matter which color in this case), while if I were to search "blue jeans" I only want the blue one to show from the whole "Levy jeans" collection.

Makes sense ? What would be the best way to implement this?
Should I just store every variant as a separate document and group the products by "master_product_id" when searching ? If yes, will this also work with grouping by also another field (I will need sometimes to also group by retailer at the same time).
Or should I use nested ? I don't think I need parent-child ?

Meaning, I want to search the whole library, and then for products that have multiple configurations, I want the highest scored product in that group. Only 5% of the products have multiple variants.

Thank You!


(system) #2