Class MerchIndexingListener
java.lang.Object
com.hybris.merchandising.indexer.listeners.MerchIndexingListener
- All Implemented Interfaces:
IndexerBatchListener,IndexerListener,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware
public class MerchIndexingListener
extends Object
implements IndexerBatchListener, org.springframework.beans.factory.BeanFactoryAware, IndexerListener
MerchIndexingListener is a listener for carrying out actions following a Solr index.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterBatch(IndexerBatchContext batchContext) Handles a notification that the processing for a particularIndexerBatchContexthas just been completed.voidafterBatchError(IndexerBatchContext batchContext) Handles a notification that the processing for a particularIndexerBatchContextfailed.voidafterIndex(IndexerContext context) Handles a notification that the indexing for a particularIndexerContexthas just been completed.voidafterIndexError(IndexerContext context) Handles a notification that the indexing for a particularIndexerContextfailed.voidbeforeBatch(IndexerBatchContext batchContext) Handles a notification that the processing for a particularIndexerBatchContextis about to begin.voidbeforeIndex(IndexerContext context) Handles a notification that the indexing for a particularIndexerContextis about to begin.protected StringcreateActionForIndexOperation(IndexOperation indexOperation) createActionForIndexOperation is a method for retrieving the action to use when sending to Merchandising for a givenIndexOperation.createFacetValueMapping(Object fieldValue, SearchQuery query, IndexedProperty indexedProperty, Object displayNameProvider) createFacetValueMapping creates a map of key -> value pairs for a given facet.protected Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> createIndexedPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery) createIndexedPropertiesMapping is a method for retrieving a map of configured key value pairs for handling mapping between Solr internal data model and what to export.protected com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfocreateIndexedPropertyInfo(SearchQuery searchQuery, IndexedProperty indexedProperty) createIndexedPropertyInfo is a method for returning anMerchIndexingListener.IndexedPropertyInforepresenting a mapping from the Solr output to the configured Merchandising specific output.protected Map<String,FacetField> createMerchFacetPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping) createMerchFacetPropertiesMapping is a method for mapping facets to output for consumption by Merchandising.createMerchFacetValues(FacetField facet, SearchQuery query, IndexedProperty indexedProperty, InputDocument document, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo indexedPropertyInfo) createMerchFacetValues is a method for retrieving the values for a provided facet.createMerchImagePropertiesMapping(List<MerchImagePropertyModel> merchImageProperties, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping) createMerchImagePropertiesMapping is an image specific method from mapping from a configured list ofMerchImagePropertyModelto the indexed properties within Solr.createMerchPropertiesMapping(List<MerchPropertyModel> merchProperties, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping) createMerchPropertiesMapping is a method for mapping from the configured list ofMerchPropertyModelto the indexed properties within Solr.protected SearchQuerycreateSearchQuery(IndexerBatchContext batchContext, MerchIndexingConfigModel merchIndexingConfig) createSearchQuery is used to generate an instance ofSearchQueryto query Solr to retrieve updated product information.protected StringextractPropName(AbstractMerchPropertyModel merchProp) extractPropName is a method for retrieving the name of an indexed property.protected StringextractPropTranslatedName is a method for retrieving the mapped name of an indexed property.protected CommonI18NServiceprotected MerchCategoryExporterprotected MerchIndexingConfigServiceprotected SessionServiceprotected booleanisMerchIndexingEnabled(Optional<MerchIndexingConfigModel> merchIdxConf) protected booleanisToSynchronize(List<CatalogVersionModel> catalogVersionsToExport, InputDocument document) isToSynchonize is a method for determining whether a given document is for the Online or Staging catalog.protected voidpopulateBasicProperties(Map<String, Object> product, IndexerBatchContext batchContext) populateBasicProperties is used to retrieve a value from theIndexerBatchContextand update it in the provided output map.protected voidpopulateMerchFacetProperties(Map<String, Object> product, InputDocument document, Map<String, FacetField> merchFacetPropertiesMapping, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, SearchQuery searchQuery) populateMerchFacetProperties is a method for populating facet information in the mapping to Merchandising.protected voidpopulateMerchImagesProperties(Map<String, Object> product, InputDocument document, Map<String, String> merchImagesPropertiesMapping, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, MerchIndexingConfigModel merchIndexingConfig) populateMerchImagesProperties is a method for retrieving values from the providedInputDocument.protected voidpopulateMerchProperties(Map<String, Object> product, InputDocument document, Map<String, String> merchPropertiesMapping, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, MerchIndexingConfigModel indexConfig) populateMerchProperties is a method for retrieving values from the providedInputDocument.protected StringresolveFacetValueDisplayName(SearchQuery searchQuery, IndexedProperty indexedProperty, Object facetDisplayNameProvider, String facetValue) resolveFacetValueDisplayName is a method for retrieving the display name for a given facet.protected ObjectresolveFacetValuesDisplayNameProvider(String beanName) resolveFacetValuesDisplayNameProvider is a utility method for retrieving a bean from the configured bean factory.protected voidsanitiseFields(Map<String, Object> product) Sanitise fields is a method for URL encoding specific fields of a product.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) voidsetCommonI18NService(CommonI18NService commonI18NService) voidsetFacetSearchService(FacetSearchService facetSearchService) voidsetFieldNameTranslator(FieldNameTranslator fieldNameTranslator) voidsetMerchCatalogServiceClient(MerchCatalogServiceClient merchCatalogServiceClient) voidsetMerchCategoryExporter(MerchCategoryExporter merchCategoryExporter) voidsetMerchIndexingConfigService(MerchIndexingConfigService merchIndexingConfigService) voidsetSessionService(SessionService sessionService) protected StringtranslateField(SearchQuery query, String field) translateField returns the translated value for a given query and field.
-
Field Details
-
DEFAULT_QUERY_TEMPLATE
- See Also:
-
EXECUTE
- See Also:
-
ID_KEY
- See Also:
-
NAME_KEY
- See Also:
-
DESCRIPTION_KEY
- See Also:
-
SUMMARY_KEY
- See Also:
-
ACTION_KEY
- See Also:
-
IMAGES_KEY
- See Also:
-
FACET_KEY
- See Also:
-
FACET_VALUES_KEY
- See Also:
-
URL_KEY
- See Also:
-
CATALOG_VERSION
- See Also:
-
CATALOG_ID
- See Also:
-
-
Constructor Details
-
MerchIndexingListener
public MerchIndexingListener()
-
-
Method Details
-
afterBatch
Handles a notification that the processing for a particularIndexerBatchContexthas just been completed.- Specified by:
afterBatchin interfaceIndexerBatchListener- Parameters:
batchContext- - theIndexerBatchContext- Throws:
IndexerException- if an error occurs
-
isToSynchronize
protected boolean isToSynchronize(List<CatalogVersionModel> catalogVersionsToExport, InputDocument document) isToSynchonize is a method for determining whether a given document is for the Online or Staging catalog.- Parameters:
catalogVersionsToExport- a list of configured catalog versions for synchronizing with Merchandising.document- theInputDocumentwhich has been indexed.- Returns:
- true if the catalog / catalog version are to be synchronized, false otherwise.
-
sanitiseFields
Sanitise fields is a method for URL encoding specific fields of a product.- Parameters:
product- the product to sanitise (as a Map).
-
createSearchQuery
protected SearchQuery createSearchQuery(IndexerBatchContext batchContext, MerchIndexingConfigModel merchIndexingConfig) throws IndexerException createSearchQuery is used to generate an instance ofSearchQueryto query Solr to retrieve updated product information.- Parameters:
batchContext- theIndexerBatchContextrepresenting the indexer batch.merchIndexingConfig- theMerchIndexingConfigModelrepresenting the config we are using for the indexing.- Returns:
- an
SearchQueryto use with the search. - Throws:
IndexerException- in case of error.
-
createIndexedPropertiesMapping
protected Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> createIndexedPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery) createIndexedPropertiesMapping is a method for retrieving a map of configured key value pairs for handling mapping between Solr internal data model and what to export.- Parameters:
batchContext- theIndexerBatchContextto retrieve from.searchQuery- theSearchQueryused to create the indexed property with.- Returns:
- a Map containing key value pairs for the mapping.
-
createIndexedPropertyInfo
protected com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo createIndexedPropertyInfo(SearchQuery searchQuery, IndexedProperty indexedProperty) createIndexedPropertyInfo is a method for returning anMerchIndexingListener.IndexedPropertyInforepresenting a mapping from the Solr output to the configured Merchandising specific output.- Parameters:
searchQuery- theSearchQuerybeing used to retrieve the value from.indexedProperty- theIndexedPropertybeing used for the query.- Returns:
- an
IndexedPropertyInforepresenting the mapping.
-
createMerchPropertiesMapping
protected Map<String,String> createMerchPropertiesMapping(List<MerchPropertyModel> merchProperties, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping) createMerchPropertiesMapping is a method for mapping from the configured list ofMerchPropertyModelto the indexed properties within Solr.- Parameters:
merchProperties- the mapping we wish to use for the output.indexedPropertiesMapping- the Solr mapping.- Returns:
- a Map containing the mapped output.
-
createMerchImagePropertiesMapping
protected Map<String,String> createMerchImagePropertiesMapping(List<MerchImagePropertyModel> merchImageProperties, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping) createMerchImagePropertiesMapping is an image specific method from mapping from a configured list ofMerchImagePropertyModelto the indexed properties within Solr.- Parameters:
merchImageProperties- the mapping we wish to use for the image output.indexedPropertiesMapping- the Solr mapping.- Returns:
- a Map containing the mapped output.
-
extractPropName
extractPropName is a method for retrieving the name of an indexed property.- Parameters:
merchProp- anAbstractMerchPropertyModelwe wish to retrieve the name of.- Returns:
- a String containing the name.
-
extractPropTranslatedName
extractPropTranslatedName is a method for retrieving the mapped name of an indexed property. If not present, we default to the name of the indexed property.- Parameters:
merchProp- theAbstractMerchPropertyModelwe wish to retrieve the name of.- Returns:
- a String containing the name.
-
createMerchFacetPropertiesMapping
protected Map<String,FacetField> createMerchFacetPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping) createMerchFacetPropertiesMapping is a method for mapping facets to output for consumption by Merchandising.- Parameters:
batchContext- theIndexerBatchContextrepresenting the indexer batch.searchQuery- theSearchQueryused for the request.indexedPropertiesMapping- the mapping used for the request.- Returns:
- a Map containing key -> facet pairs.
-
populateBasicProperties
protected void populateBasicProperties(Map<String, Object> product, IndexerBatchContext batchContext) populateBasicProperties is used to retrieve a value from theIndexerBatchContextand update it in the provided output map.- Parameters:
product- aMaprepresenting the product output.batchContext- anIndexerBatchContextto retrieve product details from.
-
populateMerchProperties
protected void populateMerchProperties(Map<String, Object> product, InputDocument document, Map<String, String> merchPropertiesMapping, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, MerchIndexingConfigModel indexConfig) populateMerchProperties is a method for retrieving values from the providedInputDocument.- Parameters:
product- aMaprepresenting the product output.document- theInputDocumentrepresenting the search result.merchPropertiesMapping- a key -> value pair mapping for mapping to Merchandising output.indexedPropertiesMapping- a map containing indexed properties.indexConfig- an instance ofMerchIndexingConfigModelcontaining the configuration being used for this indexing.
-
populateMerchImagesProperties
protected void populateMerchImagesProperties(Map<String, Object> product, InputDocument document, Map<String, String> merchImagesPropertiesMapping, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, MerchIndexingConfigModel merchIndexingConfig) populateMerchImagesProperties is a method for retrieving values from the providedInputDocument.- Parameters:
product- aMaprepresenting the product output.document- theInputDocumentrepresenting the search result.merchImagesPropertiesMapping- a key -> value pair mapping for mapping to Merchandising output.indexedPropertiesMapping- a map containing indexed properties.merchIndexingConfig- an instance ofMerchIndexingConfigModelcontaining the configuration being used for this indexing.
-
populateMerchFacetProperties
protected void populateMerchFacetProperties(Map<String, Object> product, InputDocument document, Map<String, FacetField> merchFacetPropertiesMapping, Map<String, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, SearchQuery searchQuery) populateMerchFacetProperties is a method for populating facet information in the mapping to Merchandising.- Parameters:
product- aMaprepresenting the product output.document- theInputDocumentrepresenting the search result.merchFacetPropertiesMapping- a key -> value pair mapping for mapping to Merchandising output.indexedPropertiesMapping- a map containing indexed properties.searchQuery- theSearchQuerybeing used to retrieve facets from.
-
createMerchFacetValues
protected List<Map<Object,Object>> createMerchFacetValues(FacetField facet, SearchQuery query, IndexedProperty indexedProperty, InputDocument document, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo indexedPropertyInfo) createMerchFacetValues is a method for retrieving the values for a provided facet.- Parameters:
facet- theFacetFieldwe are retrieving values for.query- theSearchQueryto retrieve values using.indexedProperty- theIndexedPropertyrepresenting the value we wish to retrieve.indexedPropertyInfo- theMerchIndexingListener.IndexedPropertyInforepresenting the field to retrieve.- Returns:
- a Map containing the facet mapping.
-
resolveFacetValuesDisplayNameProvider
resolveFacetValuesDisplayNameProvider is a utility method for retrieving a bean from the configured bean factory.- Parameters:
beanName- the bean to retrieve.- Returns:
- an
Objectrepresenting the bean if found, null otherwise.
-
resolveFacetValueDisplayName
protected String resolveFacetValueDisplayName(SearchQuery searchQuery, IndexedProperty indexedProperty, Object facetDisplayNameProvider, String facetValue) resolveFacetValueDisplayName is a method for retrieving the display name for a given facet.- Parameters:
searchQuery- theSearchQuerywe are using for the retrieval.indexedProperty- theIndexedPropertywe are retrieving.facetDisplayNameProvider- the value provider for the display name.facetValue- the value we wish to retrieve.- Returns:
- the display name for the facet.
-
createFacetValueMapping
protected Map<Object,Object> createFacetValueMapping(Object fieldValue, SearchQuery query, IndexedProperty indexedProperty, Object displayNameProvider) createFacetValueMapping creates a map of key -> value pairs for a given facet.- Parameters:
fieldValue- the value of the facet to use.query- theSearchQuerybeing used to resolve the display name from.indexedProperty- theIndexedPropertybeing used to resolve the display name from.displayNameProvider- the configured display name provider.- Returns:
- a Map containing facet value mapping.
-
translateField
translateField returns the translated value for a given query and field.- Parameters:
query- theSearchQuerywe are using to retrieve the translated value from.field- the query's field to retrieve.- Returns:
- a String containing the translated field.
-
createActionForIndexOperation
createActionForIndexOperation is a method for retrieving the action to use when sending to Merchandising for a givenIndexOperation.- Parameters:
indexOperation- the operation to retrieve the value for.- Returns:
- the action to use.
-
isMerchIndexingEnabled
-
afterIndex
Handles a notification that the indexing for a particularIndexerContexthas just been completed.- Specified by:
afterIndexin interfaceIndexerListener- Parameters:
context- - theIndexerContext- Throws:
IndexerException- if an error occurs
-
beforeBatch
Handles a notification that the processing for a particularIndexerBatchContextis about to begin.- Specified by:
beforeBatchin interfaceIndexerBatchListener- Parameters:
batchContext- - theIndexerBatchContext- Throws:
IndexerException- if an error occurs
-
afterBatchError
Handles a notification that the processing for a particularIndexerBatchContextfailed.- Specified by:
afterBatchErrorin interfaceIndexerBatchListener- Parameters:
batchContext- - theIndexerBatchContext- Throws:
IndexerException- if an error occurs
-
beforeIndex
Handles a notification that the indexing for a particularIndexerContextis about to begin.- Specified by:
beforeIndexin interfaceIndexerListener- Parameters:
context- - theIndexerContext- Throws:
IndexerException- if an error occurs
-
afterIndexError
Handles a notification that the indexing for a particularIndexerContextfailed.- Specified by:
afterIndexErrorin interfaceIndexerListener- Parameters:
context- - theIndexerContext- Throws:
IndexerException- if an error occurs
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
getFacetSearchService
-
setFacetSearchService
-
getFieldNameTranslator
-
setFieldNameTranslator
-
getMerchCatalogServiceClient
-
setMerchCatalogServiceClient
-
getMerchIndexingConfigService
-
setMerchIndexingConfigService
-
getSessionService
-
setSessionService
-
getCommonI18NService
-
setCommonI18NService
-
getMerchCategoryExporter
-
setMerchCategoryExporter
-