Class DefaultSolrCollectionResolver

java.lang.Object
com.broadleafcommerce.search.provider.solr.DefaultSolrCollectionResolver
All Implemented Interfaces:
SolrCollectionResolver

public class DefaultSolrCollectionResolver extends Object implements SolrCollectionResolver
Default implementation of the SolrCollectionResolver. This assumes that the Solr alias names are stored as properties with the following format:

broadleaf.search.{type}.primaryAlias=some_primary_alias

or

broadleaf.search.{type}.secondaryAlias=some_secondary_alias

For example:

broadleaf.search.catalog.primaryAlias=catalog_primary

Note that the values returned here could be Solr collection names, but are typically Solr aliases. Primary aliases are the aliases assigned to the foreground, primary Solr collection. Secondary alias names are meant for background collections that are typically used to do a full reindex, where the data is deleted and then reloaded. Then the collections are re-aliased, making the newly loaded collection the primary, and the previous collection the background, ready to be deleted and reloaded.

Author:
Kelly Tisdell (ktisdell)
  • Field Details

  • Constructor Details

    • DefaultSolrCollectionResolver

      public DefaultSolrCollectionResolver(@NonNull @NonNull org.springframework.core.env.Environment environment)
  • Method Details

    • getPrimarySolrCollectionForType

      public String getPrimarySolrCollectionForType(com.broadleafcommerce.search.api.type.IndexableType type)
      Description copied from interface: SolrCollectionResolver
      Retrieve the correct primary (foreground) Solr alias name for the given IndexableType.
      Specified by:
      getPrimarySolrCollectionForType in interface SolrCollectionResolver
      Parameters:
      type - Searchable type
      Returns:
      The primary alias
    • getSecondarySolrCollectionForType

      public String getSecondarySolrCollectionForType(com.broadleafcommerce.search.api.type.IndexableType type)
      Description copied from interface: SolrCollectionResolver
      Retrieve the correct secondary (background) Solr alias name for the given IndexableType.
      Specified by:
      getSecondarySolrCollectionForType in interface SolrCollectionResolver
      Parameters:
      type - Searchable type
      Returns:
      The secondary alias
    • getPrimarySolrCollectionForIndexable

      public String getPrimarySolrCollectionForIndexable(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
      Description copied from interface: SolrCollectionResolver
      Retrieve the correct primary (foreground) Solr alias name for the given Indexable.
      Specified by:
      getPrimarySolrCollectionForIndexable in interface SolrCollectionResolver
      Parameters:
      indexable - Indexable item
      Returns:
      The primary alias
    • getSecondarySolrCollectionForIndexable

      public String getSecondarySolrCollectionForIndexable(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
      Description copied from interface: SolrCollectionResolver
      Retrieve the correct secondary (background) Solr alias name for the given Indexable.
      Specified by:
      getSecondarySolrCollectionForIndexable in interface SolrCollectionResolver
      Parameters:
      indexable - Indexable item
      Returns:
      The secondary alias
    • getPrimarySolrCollectionForType

      public String getPrimarySolrCollectionForType(String type)
      Description copied from interface: SolrCollectionResolver
      Retrieve the correct primary (foreground) Solr alias name for the given type.
      Specified by:
      getPrimarySolrCollectionForType in interface SolrCollectionResolver
      Parameters:
      type - Searchable type
      Returns:
      The primary alias
    • getSecondarySolrCollectionForType

      public String getSecondarySolrCollectionForType(String type)
      Description copied from interface: SolrCollectionResolver
      Retrieve the correct secondary (background) Solr alias name for the given type.
      Specified by:
      getSecondarySolrCollectionForType in interface SolrCollectionResolver
      Parameters:
      type - Searchable type
      Returns:
      The secondary alias
    • getIndexableTypeForAlias

      @Nullable public com.broadleafcommerce.search.api.type.IndexableType getIndexableTypeForAlias(String alias)
      Description copied from interface: SolrCollectionResolver
      Return the IndexableType for the given alias. If the alias is not found, null is returned.
      Specified by:
      getIndexableTypeForAlias in interface SolrCollectionResolver
      Parameters:
      alias - The alias
      Returns:
      The IndexableType for the alias, or null if not found
    • findIndexableTypeForAlias

      @Nullable protected com.broadleafcommerce.search.api.type.IndexableType findIndexableTypeForAlias(Map<com.broadleafcommerce.search.api.type.IndexableType,String> aliasMap, String alias)