cancel
Showing results for 
Search instead for 
Did you mean: 

Only One Document contains new fields when performing a Solr Index

Former Member
0 Kudos

Running into a strange issue where only the first product document created as part of a SOLR index contains updated facet values and newly added property values. It doesn't matter which product is the first to be indexed as I've performed a full index, observed the problem, deleted the single product which was properly populated, rerun the index and observed that the next "first" product document in SOLR now contains the full dataset while the remaining product documents only contain the smaller set of fields. Even when using springELValueProvider for ootb attributes such as name or description will return null on every product but the first returned. Any suggestions or guidance would be appreciated. Thanks!

Former Member
0 Kudos

Hybris Version: 6.3

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The attributes name and description for a product are localized and if they are not indexed, it probably means that the system returns null because no text has been defined for the current locale. I assume that the locale is properly set when the indexing starts and that's why the values are properly indexed for the first product. But between the first and the second product, something changes the current locale and set it to another locale, for which no text has been defined for the name and description attributes.

The productUrlValueProvider is a possible culprit. Its method getProductUrl changes the current locale to get the product URL but does not revert back to the original current locale. If you use this value provider, it could be the reason for your problems. If you need to use this value provider, here is a possible fix:

 public class NonDisruptiveProductUrlValueProvider extends ProductUrlValueProvider
 {
     private SessionService sessionService;
 
     @Override
     protected String getProductUrl(final ProductModel product, final LanguageModel language)
     {
         return sessionService.executeInLocalView(new SessionExecutionBody()
         {
             @Override
             public Object execute()
             {
                 return NonDisruptiveProductUrlValueProvider.super.getProductUrl(product, language);
             }
         });
     }
 
     protected SessionService getSessionService()
     {
         return sessionService;
     }
 
     @Required
     public void setSessionService(SessionService sessionService)
     {
         this.sessionService = sessionService;
     }
 }

It might not be the most efficient manner but it works (eventually a try/finally could be more efficient).

Former Member
0 Kudos

Thanks Alex, using the included Value Provider did resolve the issue.

Answers (1)

Answers (1)

former_member775304
Participant
0 Kudos

Hello,

you can also use the productUrlsValueResolver which is available OOTB.