Business requirement

Imagine you have such SAP Commerce business scenario

Product Catalogue with 50,000 products

Your pricing engine supports 2,000 customer groups – meaning there are:

2,000 different groups of prices for your customers

From commerce point of view this would result in having 50,000 * 2,000 = 100,000,000 PriceRows!

100,000,000 PriceRows

Now you have two seemingly simple requirements for your B2B/B2B commerce:

  • show customer-specific price
  • still supporting OOTB feature like price range facets

How would you approach such a case then?

We have to support searching and faceting, thus the idea is to index the prices in search engine. Common case in SAP Commerce would be to represent the customer-group variants of prices as separate fields in SOLR document. This would, however, lead to the creation of documents with thousands of fields. There is generally no hardcoded limit in SOLR for the number of fields per document. Still, this is a known fact that that large documents increase significantly memory consumption an decreases the search and sort performance. That is why let’s try another approach.

Nested documents

Instead of representing the customer group prices as fields, we can use the so-called: Nested objects/documents which allow nesting of documents inside of other documents in a parent-child relationship.

SOLR product document (parent) (notice type_string field) would then look this:


SOLR nested document (child) (notice type_string field) which represents the customer-group-specific PriceRows would look like:


Then we can execute search queries on such a large index, with faceting by the nested document properties (like price) or other OOTB functionalities and still get the response within tens of miliseconds even on a non-sharded instance:

curl http://localhost:8983/solr/master_pocShop_Product/query -d '
    prices : {
      type: range,
      field: price_double,
      start : 0,
      end : 100,
      gap : 20
      domain: { blockChildren : "type_string:product" } 

Let me know in comments if the topic interested and if you want to know more details about the implementation.


Leave a Reply

Your email address will not be published. Required fields are marked *