public interface SolrHelperService
| Modifier and Type | Method and Description |
|---|---|
void |
attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
SearchCriteria searchCriteria)
Restricts the query by adding active facet filters.
|
void |
attachFacets(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap)
Notifies solr about which facets you want it to determine results and counts for.
|
void |
attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
SearchCriteria searchCriteria,
String defaultSort,
List<Field> fields)
Sets up the sorting criteria.
|
List<SearchFacetDTO> |
buildSearchFacetDTOs(List<SearchFacet> searchFacets)
Builds a list of SearchFacetDTOs from a list of SearchFacets.
|
String |
getCatalogFieldName()
The field that should store which catalog the item is being indexed for
|
String |
getCatalogOverridesFieldName()
The field that the list of catalogs that have overridden this document are in.
|
String |
getCategoryFieldName() |
Long |
getCategoryId(Category category)
In certain cases, the category id used for Solr indexing is different than the direct id on the product.
|
Long |
getCategoryId(Long category)
In certain cases, the category id used for Solr indexing is different than the direct id on the product.
|
String |
getCategorySortFieldName(Category category) |
String |
getCategorySortFieldName(Long categoryId) |
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.
|
Map<String,SearchFacetDTO> |
getNamedFacetMap(List<SearchFacetDTO> facets,
SearchCriteria searchCriteria)
Returns a map of fully qualified solr index field key to the searchFacetDTO object
|
String |
getNamespaceFieldName() |
Long |
getProductId(Product product)
In certain cases, the product id used for Solr indexing is different than the direct id on the product.
|
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
|
Object |
getPropertyValue(Object object,
Field field)
See getPropertyValue(Object, String)
|
Object |
getPropertyValue(Object object,
String propertyName)
This method is meant to behave in a similar way to Apache's PropertyUtils.getProperty(Object, String).
|
List<org.apache.solr.common.SolrDocument> |
getResponseDocuments(org.apache.solr.client.solrj.response.QueryResponse response)
Determines the list of SolrDocuments from the QueryResponse
|
String |
getSandBoxChangeTypeFieldName()
Used for DELETE documents that are extra documents created in a sandbox when an item is deleted.
|
String |
getSandBoxFieldName()
The field that stores which sandbox the document is active for.
|
String |
getSandBoxPriorityFieldName()
Which level of the priority tree the sandbox field is in like approval or user
|
List<FieldType> |
getSearchableFieldTypes(Field field)
Returns the searchable field types for the given field.
|
Long |
getSkuId(Sku sku)
In certain cases, the sku id used for Solr indexing is different than the direct id on the sku.
|
String |
getSkuIdFieldName() |
String |
getSolrDocumentId(org.apache.solr.common.SolrInputDocument document,
Product product) |
String |
getSolrDocumentId(org.apache.solr.common.SolrInputDocument document,
Sku sku) |
Map<String,String> |
getSolrFieldKeyMap(SearchCriteria searchCriteria,
List<Field> fields)
Builds a map of the fields with the abbreviation
|
String |
getSolrFieldTag(String tagField,
String tag,
SearchFacetRange range)
Returns a solr field tag.
|
String |
getSolrRangeFunctionString(BigDecimal minValue,
BigDecimal maxValue)
Returns a string representing a call to the frange solr function.
|
String |
getSolrRangeString(String fieldName,
BigDecimal minValue,
BigDecimal maxValue)
Creates a range filter (e.g.
|
String |
getSolrTaggedFieldString(String indexField,
String tag,
SearchFacetRange range)
Returns a fully composed solr field string.
|
boolean |
isFacetAvailable(SearchFacet facet,
Map<String,String[]> params)
Checks to see if the requiredFacets condition for a given facet is met.
|
void |
optimizeIndex(org.apache.solr.client.solrj.SolrServer server)
Tells Solr to optimize the index.
|
String |
sanitizeQuery(String query)
Strips out or replaces certain characters / substrings.
|
String |
scrubFacetValue(String facetValue) |
void |
setFacetResults(Map<String,SearchFacetDTO> namedFacetMap,
org.apache.solr.client.solrj.response.QueryResponse response)
Builds out the DTOs for facet results from the search.
|
void |
sortFacetResults(Map<String,SearchFacetDTO> namedFacetMap)
Invoked to sort the facet results.
|
void |
swapActiveCores()
Swaps the primary and reindex cores.
|
void swapActiveCores()
throws ServiceException
ServiceExceptionString getCurrentNamespace()
String getGlobalFacetTagField()
String getPropertyNameForFieldSearchable(Field field, FieldType searchableFieldType, String prefix)
field - searchableFieldType - prefix - String getPropertyNameForFieldFacet(Field field, String prefix)
field - prefix - List<FieldType> getSearchableFieldTypes(Field field)
field - String getPropertyNameForFieldSearchable(Field field, FieldType searchableFieldType)
field - searchableFieldType - String getPropertyNameForFieldFacet(Field field)
field - String getSolrDocumentId(org.apache.solr.common.SolrInputDocument document, Product product)
product - String getSolrDocumentId(org.apache.solr.common.SolrInputDocument document, Sku sku)
sku - String getNamespaceFieldName()
String getIdFieldName()
String getProductIdFieldName()
String getSkuIdFieldName()
String getCategoryFieldName()
String getExplicitCategoryFieldName()
String getCatalogFieldName()
String getCatalogOverridesFieldName()
The field that the list of catalogs that have overridden this document are in. In a multitenant environment this works like so:
getProductIdFieldName() == 5getCatalogFieldName() == 1getProductIdFieldName() == 5getCatalogFieldName() == 2 (note that it uses the MASTER_CATALOG product ID and not the cloned id)
getCatalogFieldName() == 1 and
getProductIdFieldName() == 5 and then adds to the list of getCatalogOverridesFieldName(), id 2.getCatalogOverridesFieldName()
contain the current catalog are filtered out.String getSandBoxFieldName()
String getSandBoxPriorityFieldName()
SandBoxType}String getSandBoxChangeTypeFieldName()
String getCategorySortFieldName(Category category)
category - String getCategorySortFieldName(Long categoryId)
categoryId - String getLocalePrefix()
String getDefaultLocalePrefix()
Locale getDefaultLocale()
Long getCategoryId(Category category)
category - Long getCategoryId(Long category)
category - Long getProductId(Product product)
product - Long getSkuId(Sku sku)
sku - Object getPropertyValue(Object object, Field field) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
object - field - NoSuchMethodExceptionInvocationTargetExceptionIllegalAccessExceptionObject getPropertyValue(Object object, String propertyName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
This method is meant to behave in a similar way to Apache's PropertyUtils.getProperty(Object, String). This is attempting to get the value or values for a property using the property name specified in field.getPropertyName(). The real difference with this method is that it iterates over Collections, Map values, and arrays until it reaches end of the property name. For example, consider a Product and the property name "defaultSku.fees.currency.currencyCode".
The property "fees" is a collection of SkuFee objects on the Sku. If an Product is passed to this method, with a field defining a property name of "defaultSku.fees.currency.currencyCode", this method will return a Collection of Strings. Specifically, it will return a Set of Strings.
The point is, for Solr indexing, it is often desirable to specify all of the values associated with a product for a given Solr field. In this case, you are trying to get all of the unique currency codes associated with the collection of fees associated with the default Sku for the given product.
This works similarly for Maps, Collections, Dates, Strings, Integers, Longs, and other primitives. Note, though, that this will return complex objects as well, if you do not specify the more primitive property that you are trying to access. For example, if you used "defaultSku.fees.currency" as a property name, you would get a collection of BroadleafCurrency objects back. Solr will not be happy if you try to index these.
Note that, for arrays, this method only works with one dimensional arrays.
For Maps, if a key is not specified, this method ignores the key, and iterates over the values collection and treats the values the same way that it treats any other collection. If they key is specified, then this method returns the keyed value rather than all of the values.
So, for example, if you have a product and a property such as "productAttributes(heatRange).value", it will return a single value if there is a ProductAttribute keyed by "heatRange", or null if there is not. If you use the property "productAttributes.value" then is will return a collection of the values associated with each of the values in the productAttributes map.
In this regard it is quite different than PropertyUtils.getMappedProperty(Object, String).
Keep in mind that, since this method returns either a Collection or a single object that is not a Map or Array, you need to make sure that the field can handle such a value. For example, if your field is intended to index a collection of Strings, you need to make sure Solr's definition of this field (or dynamic field) is a multi-valued type according to your Solr schema definition (e.g. _txt or _ss or _is, etc.).
object - propertyName - NoSuchMethodExceptionInvocationTargetExceptionIllegalAccessExceptionvoid optimizeIndex(org.apache.solr.client.solrj.SolrServer server)
throws ServiceException,
IOException
server - ServiceExceptionIOExceptionString sanitizeQuery(String query)
query - List<SearchFacetDTO> buildSearchFacetDTOs(List<SearchFacet> searchFacets)
searchFacets - boolean isFacetAvailable(SearchFacet facet, Map<String,String[]> params)
facet - params - String getSolrRangeString(String fieldName, BigDecimal minValue, BigDecimal maxValue)
fieldName - minValue - maxValue - String getSolrRangeFunctionString(BigDecimal minValue, BigDecimal maxValue)
minValue - maxValue - String getSolrFieldTag(String tagField, String tag, SearchFacetRange range)
tagField - tag - range - void setFacetResults(Map<String,SearchFacetDTO> namedFacetMap, org.apache.solr.client.solrj.response.QueryResponse response)
namedFacetMap - response - void sortFacetResults(Map<String,SearchFacetDTO> namedFacetMap)
namedFacetMap - void attachFacets(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap)
query - namedFacetMap - String getSolrTaggedFieldString(String indexField, String tag, SearchFacetRange range)
indexField - tag - range - List<org.apache.solr.common.SolrDocument> getResponseDocuments(org.apache.solr.client.solrj.response.QueryResponse response)
response - void attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
SearchCriteria searchCriteria,
String defaultSort,
List<Field> fields)
query - searchCriteria - defaultSort - fields - Map<String,String> getSolrFieldKeyMap(SearchCriteria searchCriteria, List<Field> fields)
searchCriteria - fields - Map<String,SearchFacetDTO> getNamedFacetMap(List<SearchFacetDTO> facets, SearchCriteria searchCriteria)
facets - searchCriteria - void attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
SearchCriteria searchCriteria)
query - namedFacetMap - searchCriteria - Copyright © 2017. All rights reserved.