Situation
SAP hybris works with Apache SOLR to provide enhanced product search capabilities.
There are two SOLR modes: indexing and search. In the indexing mode hybris fetches new products from the database and sends them to SOLR to index.
Complexity
This operation is quite expensive in terms of performance since the product data needs to be collected from the different database tables. To change only one attribute in the SOLR index you need to fetch all the attributes and update the SOLR document completely.
For example, you want to store price information in the index to make price range filtering possible. When the price is changed you will need to fetch all the product attributes and update the whole SOLR document using standard out-of-the-box SOLR indexer configuration. If the product price is changed frequently, the indexing process is going to be a bottleneck.
Challenge
How to make the update operation faster if the changes are minor? How to update only one attribute in the SOLR document?
Solution
Apache SOLR in the standalone mode has a simple and well-documented indexer interface. For example, if you need to update the price attribute only, you can make a http request to the SOLR server:
curl 'http://localhost:8983/solr/master_My_Product/update?commit=true'
-H 'Content-type:application/json'
-d'[{"id":"ElectronicsProductCatalog/Online/<PRODUCTCODE>",
"priceValue_usd_double":{"set":"1020.00"}}]'
- master_My_Product is a name of SOLR core
- ElectronicsProductCatalog is a name of product catalog
- <PRODUCTCODE> is a product Code
Another example is about updating the availability status:
curl 'http://localhost:8983/solr/master_My_Product/update?commit=true'
-H 'Content-type:application/json'
-d'[{"id":"ElectronicsProductCatalog/Online/<PRODUCTCODE>",
"inStockFlag_boolean":{"set":"false"}}]'
© Rauf Aliev, June 2016