org.broadleafcommerce.core.search.service.solr
Class SolrHelperServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.core.search.service.solr.SolrHelperServiceImpl
All Implemented Interfaces:
SolrHelperService

@Service(value="blSolrHelperService")
public class SolrHelperServiceImpl
extends Object
implements SolrHelperService

Provides utility methods that are used by other Solr service classes

Author:
Andre Azzolini (apazzolini)

Field Summary
protected static String DEFAULT_NAMESPACE
           
protected static Locale defaultLocale
           
protected  SolrSearchServiceExtensionManager extensionManager
           
protected static String GLOBAL_FACET_TAG_FIELD
           
protected  LocaleService localeService
           
protected static String PREFIX_SEPARATOR
           
protected static org.apache.solr.client.solrj.SolrServer server
           
 
Constructor Summary
SolrHelperServiceImpl()
           
 
Method Summary
protected  String convertPrefixListToString(List<String> prefixList)
           
 String getCategoryFieldName()
           
 String getCategorySortFieldName(Category category)
           
 String getCurrentNamespace()
          Determines the current namespace we are operating on.
 Locale getDefaultLocale()
          Returns the default locale.
 String getDefaultLocalePrefix()
           
 String getExplicitCategoryFieldName()
           
 String getGlobalFacetTagField()
          This property is needed to be non-null to allow filtering by multiple facets at one time and have the results be an AND of the facets.
 String getIdFieldName()
           
 String getLocalePrefix()
          Determines if there is a locale prefix that needs to be applied to the given field for this particular request.
 String getNamespaceFieldName()
           
 String getProductIdFieldName()
           
 String getPropertyNameForFieldFacet(Field field)
          Returns the property name for the given field and its configured facet field type.
 String getPropertyNameForFieldFacet(Field field, String prefix)
          Returns the property name for the given field, its configured facet field type, and the given prefix
 String getPropertyNameForFieldSearchable(Field field, FieldType searchableFieldType)
          Returns the property name for the given field and field type.
 String getPropertyNameForFieldSearchable(Field field, FieldType searchableFieldType, String prefix)
          Returns the property name for the given field, field type, and prefix
 List<FieldType> getSearchableFieldTypes(Field field)
          Returns the searchable field types for the given field.
 String getSolrDocumentId(org.apache.solr.common.SolrInputDocument document, Product product)
           
 void swapActiveCores()
          Swaps the primary and reindex cores.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL_FACET_TAG_FIELD

protected static final String GLOBAL_FACET_TAG_FIELD
See Also:
Constant Field Values

DEFAULT_NAMESPACE

protected static final String DEFAULT_NAMESPACE
See Also:
Constant Field Values

PREFIX_SEPARATOR

protected static final String PREFIX_SEPARATOR
See Also:
Constant Field Values

defaultLocale

protected static Locale defaultLocale

server

protected static org.apache.solr.client.solrj.SolrServer server

localeService

protected LocaleService localeService

extensionManager

protected SolrSearchServiceExtensionManager extensionManager
Constructor Detail

SolrHelperServiceImpl

public SolrHelperServiceImpl()
Method Detail

swapActiveCores

public void swapActiveCores()
                     throws ServiceException
Description copied from interface: SolrHelperService
Swaps the primary and reindex cores. If the reindex core is null, we are operating in single core mode. In this scenario, no swap occurs.

Specified by:
swapActiveCores in interface SolrHelperService
Throws:
ServiceException

getCurrentNamespace

public String getCurrentNamespace()
Description copied from interface: SolrHelperService
Determines the current namespace we are operating on. For example, if you have multiple sites set up, you may want to filter that here.

Specified by:
getCurrentNamespace in interface SolrHelperService
Returns:
the global namespace

getGlobalFacetTagField

public String getGlobalFacetTagField()
Description copied from interface: SolrHelperService
This property is needed to be non-null to allow filtering by multiple facets at one time and have the results be an AND of the facets. Apart from being non-empty, the actual value does not matter.

Specified by:
getGlobalFacetTagField in interface SolrHelperService
Returns:
the non-empty global facet tag field

getPropertyNameForFieldSearchable

public String getPropertyNameForFieldSearchable(Field field,
                                                FieldType searchableFieldType,
                                                String prefix)
Description copied from interface: SolrHelperService
Returns the property name for the given field, field type, and prefix

Specified by:
getPropertyNameForFieldSearchable in interface SolrHelperService
Returns:
the property name for the field and fieldtype

getPropertyNameForFieldFacet

public String getPropertyNameForFieldFacet(Field field,
                                           String prefix)
Description copied from interface: SolrHelperService
Returns the property name for the given field, its configured facet field type, and the given prefix

Specified by:
getPropertyNameForFieldFacet in interface SolrHelperService
Returns:
the property name for the facet type of this field

getSearchableFieldTypes

public List<FieldType> getSearchableFieldTypes(Field field)
Description copied from interface: SolrHelperService
Returns the searchable field types for the given field. If there were none configured, will return a list with TEXT FieldType.

Specified by:
getSearchableFieldTypes in interface SolrHelperService
Returns:
the searchable field types for the given field

getPropertyNameForFieldSearchable

public String getPropertyNameForFieldSearchable(Field field,
                                                FieldType searchableFieldType)
Description copied from interface: SolrHelperService
Returns the property name for the given field and field type. This will apply the global prefix to the field, and it will also apply either the locale prefix or the pricelist prefix, depending on whether or not the field type was set to FieldType.PRICE

Specified by:
getPropertyNameForFieldSearchable in interface SolrHelperService
Returns:
the property name for the field and fieldtype

getPropertyNameForFieldFacet

public String getPropertyNameForFieldFacet(Field field)
Description copied from interface: SolrHelperService
Returns the property name for the given field and its configured facet field type. This will apply the global prefix to the field, and it will also apply either the locale prefix or the pricelist prefix, depending on whether or not the field type was set to FieldType.PRICE

Specified by:
getPropertyNameForFieldFacet in interface SolrHelperService
Returns:
the property name for the facet type of this field

convertPrefixListToString

protected String convertPrefixListToString(List<String> prefixList)

getSolrDocumentId

public String getSolrDocumentId(org.apache.solr.common.SolrInputDocument document,
                                Product product)
Specified by:
getSolrDocumentId in interface SolrHelperService
Returns:
the Solr id of this product

getNamespaceFieldName

public String getNamespaceFieldName()
Specified by:
getNamespaceFieldName in interface SolrHelperService
Returns:
the name of the field that keeps track what namespace this document belongs to

getIdFieldName

public String getIdFieldName()
Specified by:
getIdFieldName in interface SolrHelperService
Returns:
the id field name, with the global prefix as appropriate

getProductIdFieldName

public String getProductIdFieldName()
Specified by:
getProductIdFieldName in interface SolrHelperService
Returns:
the productId field name

getCategoryFieldName

public String getCategoryFieldName()
Specified by:
getCategoryFieldName in interface SolrHelperService
Returns:
the category field name, with the global prefix as appropriate

getExplicitCategoryFieldName

public String getExplicitCategoryFieldName()
Specified by:
getExplicitCategoryFieldName in interface SolrHelperService
Returns:
the explicit category field name, with the global prefix as appropriate

getCategorySortFieldName

public String getCategorySortFieldName(Category category)
Specified by:
getCategorySortFieldName in interface SolrHelperService
Returns:
the default sort field name for this category

getLocalePrefix

public String getLocalePrefix()
Description copied from interface: SolrHelperService
Determines if there is a locale prefix that needs to be applied to the given field for this particular request. By default, a locale prefix is not applicable for category, explicitCategory, or fields that have type Price. Also, it is not applicable for non-translatable fields

Specified by:
getLocalePrefix in interface SolrHelperService
Returns:
the global prefix if there is one, "" if there isn't

getDefaultLocalePrefix

public String getDefaultLocalePrefix()
Specified by:
getDefaultLocalePrefix in interface SolrHelperService
Returns:
the default locale's prefix

getDefaultLocale

public Locale getDefaultLocale()
Description copied from interface: SolrHelperService
Returns the default locale. Will cache the result for subsequent use. Note: There is no currently configured cache invalidation strategy for the the default locale. Override this method to provide for one if you need it.

Specified by:
getDefaultLocale in interface SolrHelperService
Returns:
the default locale


Copyright © 2013. All Rights Reserved.