We are using SOLR to index products for an eCommerce application, we have products grouped by category and subcategories and the same product can appear in more than one subcategory, We need to retrieve the products in all the subcategories it belongs to and would like to use one single query to achieve this objective. Any pointers would be really helpful. Example illustrated below -
Assume that a product p1 belongs to subcategory sc1 and sc2 which belongs to parent category c1
c1 ----- sc1 ----- p1
c1 ----- sc2 ----- p1
The way we have indexed the product is to have category path information in product p1, p1 - Category path of (c1->sc1 and c1->sc2)
When the user browses through the category c1 the product should appear twice on the page grouped by subcategory sc1 and sc2 as shown below
c1 ----- sc1
p1
----- sc2
p1
We want to query from solr so that it returns the same product grouped in 2 different subcategories, effectively duplicating in the result. We could do it programatically after fetching the result from solr but we have pagination and sort order logic which would be hard to maintain in the code.