org.broadleafcommerce.core.search.service.solr.SolrHelperService Maven / Gradle / Ivy
/*
* Copyright 2008-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.broadleafcommerce.core.search.service.solr;
import org.broadleafcommerce.common.exception.ServiceException;
import org.broadleafcommerce.common.locale.domain.Locale;
import org.broadleafcommerce.core.catalog.domain.Category;
import org.broadleafcommerce.core.search.domain.Field;
import org.broadleafcommerce.core.search.domain.solr.FieldType;
/**
* @author Andre Azzolini (apazzolini)
*/
public 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.
*
* @throws ServiceException
*/
public void swapActiveCores() throws ServiceException;
/**
* Determines the current namespace we are operating on. For example, if you have multiple sites set up,
* you may want to filter that here.
*
*
* - Note: This method should ALWAYS return a non-empty string.
*
*
* @return the global namespace
*/
public String getCurrentNamespace();
/**
* 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.
*
* @return the non-empty global facet tag field
*/
public String getGlobalFacetTagField();
/**
* Returns the property name for the given field, field type, and prefix
*
* @param field
* @param searchableFieldType
* @param prefix
* @return the property name for the field and fieldtype
*/
public String getPropertyNameForFieldSearchable(Field field, FieldType searchableFieldType, String prefix);
/**
* Returns the property name for the given field, its configured facet field type, and the given prefix
*
* @param field
* @param prefix
* @return the property name for the facet type of this field
*/
public String getPropertyNameForFieldFacet(Field field, String prefix);
/**
* 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
*
* @param field
* @param searchableFieldType
* @return the property name for the field and fieldtype
*/
public String getPropertyNameForFieldSearchable(Field field, FieldType searchableFieldType);
/**
* 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
*
* @param field
* @return the property name for the facet type of this field
*/
public String getPropertyNameForFieldFacet(Field field);
/**
* @return the name of the field that keeps track what namespace this document belongs to
*/
public String getNamespaceFieldName();
/**
* @return the id field name, with the global prefix as appropriate
*/
public String getIdFieldName();
/**
* @return the category field name, with the global prefix as appropriate
*/
public String getCategoryFieldName();
/**
* @return the explicit category field name, with the global prefix as appropriate
*/
public String getExplicitCategoryFieldName();
/**
* @param prefix
* @return the searchable field name, with the global and specific prefix as appropriate
*/
public String getSearchableFieldName(String prefix);
/**
* @return the searchable field name, with the global and locale prefixes as appropriate
*/
public String getSearchableFieldName();
/**
* @param category
* @return the default sort field name for this category
*/
public String getCategorySortFieldName(Category category);
/**
* 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
*
*
* - Note: This method should NOT return null. There must be a default locale configured.
*
*
* @return the global prefix if there is one, "" if there isn't
*/
public String getLocalePrefix();
/**
* @return the default locale's prefix
*/
public String getDefaultLocalePrefix();
/**
* 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.
*
* @return the default locale
*/
public Locale getDefaultLocale();
}