Class SearchFacetUtils<F extends com.broadleafcommerce.search.api.domain.Facet>
java.lang.Object
com.broadleafcommerce.search.core.service.facet.SearchFacetUtils<F>
public class SearchFacetUtils<F extends com.broadleafcommerce.search.api.domain.Facet>
extends Object
Utilities for working with
Facets.- Since:
- 2.1.0-GA
- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
ConstructorsConstructorDescriptionSearchFacetUtils(SettingsFacetGroupService<com.broadleafcommerce.search.api.domain.SettingsFacetGroup> settingsFacetGroupService, FacetGroupService<com.broadleafcommerce.search.api.domain.FacetGroup> facetGroupService, FacetGroupFacetService<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacetService, FacetService<F> facetService, com.broadleafcommerce.search.autoconfigure.SearchSettingsProperties searchSettingsProperties, SearchSettingsUtils searchSettingsUtils) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidattachFacetsToFacetGroupFacets(@NonNull List<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacets, @NonNull Map<String, F> facetMapById) buildOrderFacetsStream(@NonNull List<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacets, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) determineAvailableFacetsForFacetGroup(com.broadleafcommerce.search.api.domain.SettingsFacetGroup settingsFacetGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines the list of available facets for the givenSettingsFacetGroup.determineFacetsForSearchRequest(@NonNull List<? extends com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, String indexableType, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) determineOrderedFacets(@NonNull Stream<String> orderedFacetIds, @NonNull Map<String, F> facetMapById, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<com.broadleafcommerce.search.api.domain.SettingsFacetGroup>determineSettingsFacetGroup(com.broadleafcommerce.search.api.domain.SearchSettings searchSettings, String indexableType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) gatherFacetIdsByDisplayOrder(@NonNull List<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacets, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) gatherFacetIdsBySort(@NonNull List<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacets, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected FacetGroupFacetService<com.broadleafcommerce.search.api.domain.FacetGroupFacet>protected FacetGroupService<com.broadleafcommerce.search.api.domain.FacetGroup>protected FacetService<F>protected com.broadleafcommerce.search.autoconfigure.SearchSettingsPropertiesprotected SearchSettingsUtilsprotected SettingsFacetGroupService<com.broadleafcommerce.search.api.domain.SettingsFacetGroup>voidhydrateFacetsOntoFields(@NonNull com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, @NonNull List<? extends com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) HydratesFacetsonto the providedFieldDefinitionsfor the givenSearchRequest.readFacetsById(@NonNull List<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacets, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Constructor Details
-
SearchFacetUtils
public SearchFacetUtils(SettingsFacetGroupService<com.broadleafcommerce.search.api.domain.SettingsFacetGroup> settingsFacetGroupService, FacetGroupService<com.broadleafcommerce.search.api.domain.FacetGroup> facetGroupService, FacetGroupFacetService<com.broadleafcommerce.search.api.domain.FacetGroupFacet> facetGroupFacetService, FacetService<F> facetService, com.broadleafcommerce.search.autoconfigure.SearchSettingsProperties searchSettingsProperties, SearchSettingsUtils searchSettingsUtils)
-
-
Method Details
-
hydrateFacetsOntoFields
public void hydrateFacetsOntoFields(@NonNull @NonNull com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, @NonNull @NonNull List<? extends com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) HydratesFacetsonto the providedFieldDefinitionsfor the givenSearchRequest. IfSearchSettings are enabled, then this will look up theSearchSettingsfirst to find the appropriate settings for the application or tenant in context. Then it will clear all facet related fields on the field definitions and re-hydrate them based on the facets configured. Otherwise, it will simply pass the field definitions through as they already have the appropriate information.This will use a copy of the given
ContextInfothat hasContextInfo.isIgnoreCatalogNarrowing()set to true when reading search settings and related domain since the Catalog ID on the request will be for the indexable type being queried on not the Search Group the settings belong to.- Parameters:
searchRequest- Incoming requestfieldDefinitions- List of resolvedFieldDefinitionsappropriate for the indexable type.originalContext- Additional sandbox and multitenant info.
-
determineFacetsForSearchRequest
-
determineAvailableFacetsForFacetGroup
protected List<F> determineAvailableFacetsForFacetGroup(com.broadleafcommerce.search.api.domain.SettingsFacetGroup settingsFacetGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines the list of available facets for the givenSettingsFacetGroup. The facets will be ordered first by the Sort value of theirFacetGroupFacet, and then by theFacet.getDisplayOrder(), if the Sort value is not set.- Parameters:
settingsFacetGroup- theSettingsFacetGroupto determine facets forcontextInfo- The context information surrounding sandboxing/multitenant state- Returns:
- the list of available facets for the given
SettingsFacetGroup
-
determineSettingsFacetGroup
-
readFacetsById
-
attachFacetsToFacetGroupFacets
-
buildOrderFacetsStream
-
gatherFacetIdsBySort
-
gatherFacetIdsByDisplayOrder
-
determineOrderedFacets
-
getSettingsFacetGroupService
protected SettingsFacetGroupService<com.broadleafcommerce.search.api.domain.SettingsFacetGroup> getSettingsFacetGroupService() -
getFacetGroupService
protected FacetGroupService<com.broadleafcommerce.search.api.domain.FacetGroup> getFacetGroupService() -
getFacetGroupFacetService
protected FacetGroupFacetService<com.broadleafcommerce.search.api.domain.FacetGroupFacet> getFacetGroupFacetService() -
getFacetService
-
getSearchSettingsProperties
protected com.broadleafcommerce.search.autoconfigure.SearchSettingsProperties getSearchSettingsProperties() -
getSearchSettingsUtils
-