Tags

8 pages

Apache Solr

How to use same solr index for different index types

There are cases, when it is required to use same solr index to index/search different itemtypes. For example, it is required to have in search box autocompletion different types, like Product and Media. Another common use case would be display on search result page search results of different itemtypes mixed together (for example, Product, Media, custom Resource itemtype).

Fix wrong session user during Solr Hot reindex

Solr hot update indexing always uses current session user, for example current backoffice user, who triggered solr hot reindex. In lots of real world cases it would lead to wrong results in solr due to different flexible search restrictions, which are applied to backoffice user and solr indexing user.

How to add flexible search restriction for Product with custom session attribute and resolve all exceptions

OOTB hybris has a powerful “Flexible Search Restriction” system, which allows transparently restrict access to any hybris item type. Due to flexible search restrictions are implemented on a very low level of hybris ORM time to time unexpected issues can appear even for simple restrictions.

Synchronize catalogs from business process

Starting catalog synchronization with CatalogVersionSyncJob in a bussiness process action leads to “Error in worker SyncWorker : Entity not found ( pk = 8794627343487 name = ‘de.hybris.platform.persistence.processing_CronJob’ type code = ‘501’ db table = ‘cronjobs’)”. I didn’t find a way to fix such behaviour of syncing inside business process action, but I resolved this issue by triggering event from process action and running SyncJob in event listener. For me sync performs well only via SetupSyncJobService, performing job via CatalogSynchronizationService causes exception in SyncWorker.

Switch solr client on POST requests

From time to time I have been receiving from customer support service messages that filter functionality on PLP returns no results. Finally, after 1 year of such messages our QA team was able to reproduce the issue. The root of the issue is too many filters, which causes creation of very long requests, which can’t be processed by solr server. Solr server is shipped with Jetty, which has 8KB limit to URL length. You can change this limit by adding <Set name="requestHeaderSize"> 200000 </Set> to server/contexts/solr-jetty-context.xml. After discussions with DevOps Lead and Tech Lead we decided that in our case will be better to force hybris solr client to use POST requests instead of GET and don’t change solr server OOTB settings (by default Jetty has limitation to 200KB for POST body). Unfortunately hybris doesn’t provide any configuration for such switching, and it must be done manually by overriding DefaultFacetSearchStrategy.