Sitecore Commerce Connect Product Sync with Solr

If you are using Solr with Sitecore Commerce Connect 8.0 and Sitecore XP 8.0 update 6 (not using Sitecore 8.1) you may have issues with Product Sync taking a longer time to complete.

First of all check compatibility of Sitecore XP and Sitecore Commerce Connect here

Product Sync process uses the pipeline "Sitecore.Commerce.Pipelines.Products.GetSitecoreProductList.GetSitecoreProductList” to generate a list of products already in Sitecore. It then compares this list with another list of ECS products (products available in External Commerce System). Pipelines performs union and delta and make a list of products that needs to be deleted, updated or inserted in Sitecore.

When using Solr, the pipeline returns only 500 Products available in Sitecore (you can see the count by overriding the pipeline and adding logs to check product count) although there were more than 20K products in the product repository. commerce_products_master_index returns 26250 products.

As a result of this, it was deleting existing products (26250 - 500) and re-creating those products. It takes a longer time for the sync to complete.

The logs show the following query being executed

?q=((_language:(en) AND _latestversion:(1)) AND _template:(47d1a39e3b4b4428a9f8b446256c9581))&rows=500&fl=_uniqueid,_datasource&fq=_indexname:(commerce_products_master_index)

As you can see the "rows" parameter is set to "500", which means that the maximum number of results that the query should return is 500.

The value of the parameter is set according to the value of the "ContentSearch.SearchMaxResults" setting of your environment. The result configuration of my environment shows that the setting value was set to 500.

In General, GetSitecoreProductList is always returning 500 products when using Solr and when changing commerce_products_master_index index back to Lucene, the pipeline is giving the correct product count.

The behaviour was caused by the fact that "ContentSearch.SearchMaxResults" setting is defined in the two configuration files:

/App_Config/Include/Sitecore.ContentSearch.config    (the file contains the setting but it is commented out by default)

/App_Config/Include/Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config    (the file contains the setting and it is set to "500")

If you enable Lucene then the setting is disabled - no limit for search results.
If you enable Solr then the setting is enabled and a limit applies to search results.

The behavior has been fixed in Sitecore Experience Platform 8.1 (rev. 151003).

Solution for Sitecore XP 8.0: Comment out the setting ContentSearch.SearchMaxResults in the /App_Config/Include/Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file

It could have an impact on the performance of a query if it returns a significant set of results.

But you can limit the results count of a query using the "partitioning" operators.

For more details please see partitioning operators ("Take", etc.) that are described in the guide:'s_guide_to_item_buckets_and%20search_sc75-a4.pdf