0

I'm working with Solr and facing a challenge related to sorting parent documents based on values from associated child documents.

Scenario:

  1. I have two types of documents: products (as parent documents) and reviews (as child documents). (They are located at different cores)
  2. Each product has a unique product_id.
  3. Each review references a product via a product_id field.
  4. I want to retrieve and sort products based on some aggregate value from their reviews (e.g., average review score).

From my understanding, Solr doesn't support a direct method to sort parent documents by aggregated values of child documents, like a traditional SQL JOIN with GROUP BY and ORDER BY would.

Question:

  1. What is the recommended approach to achieve this sorting in Solr?
  2. Are there any workarounds or third-party extensions that could assist in this?

I've considered denormalizing the data and incorporating the average review score directly into the product document at index time, but I wonder if there's a more dynamic approach that doesn't require re-indexing products when new reviews are added.

Any guidance would be greatly appreciated!

Just FYI I use {!join from=product_id to=id}*:* syntax to receive the result set.

0 Answers0