Salesforce Commerce Search Settings API
The Salesforce Commerce Search Settings APIs assist in managing and optimizing search functionality within the Commerce Cloud platform. These APIs are categorized for both the shopper's experience and the administrative setup. Key functionalities include configuring search indexes, handling search suggestions, performing product searches, and managing search-related attributes.
You must first set up your products by creating them, defining custom attributes, and importing them into the store to effectively use the Search Settings APIs.
The Facetable Attributes API defines which product attributes can be used as facets in search results. Attributes like category, brand, size, and color are displayed in the left-hand navigation on the Product Listing Page (PLP), helping users refine their search results.
The Searchable Attributes API specifies which attributes are searchable. Not all product attributes are relevant for text searches. For example, if you type "shirt" in the search box, this API determines which fields must be searched for that word.
The Sort Rules API enables sorting of search results, which is useful for category-based searches where all products in a category have the same relevancy. You can sort products by conditions such as name or price, in ascending or descending order.
Additionally, you can use the Include Rules API to add synonyms for search terms. This API only supports single-word synonyms. For example, "jacket" can be configured as a synonym for "wintercoat", so searching for either term returns similar results.
The Boost and Bury Rules API adjusts the visibility of products based on their relevancy-based scoring. It allows you to boost the relevancy of certain products, making them appear higher in search results, or bury them to decrease their relevancy. You can also define a time period for these rules. This changes the product's relevance for all searches. The API supports creating, retrieving, and deleting boost and bury rules.
After you've created attributes and rules, you need to add data from the product catalog to the search index. Product indexing improves search performance and speed. The Indexing APIs help you set up a search index for your store. The API supports creating an index for a product catalog on a webstore or retrieving index information for the entire webstore. Additionally, the Index Log API helps you retrieve search index logs for a webstore.
The Search Suggestions and Product Search APIs enhance the shopper's experience. The Search Suggestions API provides real-time suggestions as users type in the search box. This API improves the user experience by quickly offering relevant suggestions. For example, when a user types "shirt", the API suggests terms like "men shirt" and "women shirt". The Product Search API conducts the actual search based on the entered search terms or filters. After a suggestion is selected or the search term is fully entered, the API retrieves a list of matching products, applying filters such as category and refinement. For example, if you select the category "clothing" and specify "red" as the refinement, the API returns red shirts.
Let's consider a basic scenario for building a flow using Search Settings APIs. This example covers just a few Search Settings APIs and doesn't include the entire APIs functionality.
Before using the Search Settings APIs, ensure your products are set up in the store.
Let’s assume a product wasn’t configured as searchable during its creation. You can make a PATCH request to the Webstore Search Product Settings API to set the product as searchable.
Next, to add a new facet, such as the attribute "red" under the parent facet "color," make a PUT request to the Webstore Search Facetable Attributes API, including the new attribute "red" with the existing ones. These facets appear in the left-hand navigation on the Product Listing Page (PLP). Additionally, define which attributes are searchable by making a PATCH request to the Webstore Search Searchable Attributes API.
After defining the attributes and setting them as searchable, update your store index to reflect these changes. Make a POST request to the Webstore Search Indexes API to create an index. This live index replaces the current one and removes any in-progress indexes.
When your store is ready, as a shopper types "shirt," a GET request to the Webstore Product Search Suggestions API returns suggestions like "shirt men" and "shirt women." After selecting a suggestion or fully entering the search term, make a POST request to the Commerce Webstore Product Search API to retrieve a list of products matching the search term, applying filters such as "red" for color.
Here’s a list of Search Settings resources: