Broadleaf Microservices
  • v1.0.0-latest-prod

Catalog Browse Catalog Search Provider

Overview

Provider that interfaces with the Search Engine to supply catalog search results and search suggestions (i.e., type-ahead results). The default implementation facilitates HTTP requests against the Search Services endpoints. The Search Engine should provide product results, filters, sort options, and highlights for suggestions.

Default Implementation Details

The default implementation, ExternalCatalogSearchProvider, primarily allows requests to pass-through to the Search Engine then hydrates pricing on the response due to limitations in the current Search Services implementation. We will also hydrate ProductTags since the search results don’t include the display values like badgeMessage, position, and badgeAsset. Finally, a Product’s additional assets can be hydrated by setting broadleaf.catalogbrowse.catalogsearchprovider.hydrateAssets to true.

Tip
The latter is useful when indexing products with the product option values (such as color) so that the correct asset can be displayed matching the particular of the version of the product . For example product "t-shirt" might be indexed per each color variation, so we want to show the correct asset for that variation rather than the same primary asset for each. This makes it easy to distinguish the results on the storefront for the customer.

CatalogSearchProvider can be treated as an integration hook-point for any additional information hydration from other services.

Configuration

ExternalCatalogSearchProvider defines the following configuration properties:

  • broadleaf.catalogbrowse.catalogsearchprovider.url: The base url for an external search service.

  • broadleaf.catalogbrowse.catalogsearchprovider.searchUri: The context path for retrieving search results. This is appended to the url property.

  • broadleaf.catalogbrowse.catalogsearchprovider.suggestUri: The context path for retrieving typeahead suggestions. This is appended to the url property.

  • broadleaf.catalogbrowse.catalogsearchprovider.hydrateAssets: Determines whether an additional call to Catalog Services should be made to hydrate the search results with additional product assets. Default is false.

Example of building request from properties
UriComponentsBuilder.fromHttpUrl(getUrl())
        .path(getProductsUri())
        .queryParam("query", "hot sauce")
        .queryParam("size", "15")
        .queryParam("page", "2")
        .queryParam("sort", "name,asc")
        .queryParam("filters[0].name", "price")
        .queryParam("filters[0].ranges[0].minValue", "10.00")
        .queryParam("filters[0].ranges[0].maxValue", "50.00")
        .queryParam("filters[1].name", "primaryCategoryId")
        .queryParam("filters[1].values", "merchandise-123")
        .queryParam()
        .toUriString();