Salesforce Commerce Search Settings API
The Salesforce Commerce Search Settings APIs assist in managing and optimizing search functionality within the B2B Commerce 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.
To effectively use the Search Settings APIs, set up your products by creating them, defining custom attributes, and importing them into the store.
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 Commerce Management Webstore Search, Include Rules to add synonyms for search terms. This API supports both single-word and multi-word synonyms. For example, if you configure "jacket" as a synonym for "winter coat" and "wintercoat", either search 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, 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 web store or retrieving index information for the entire web store. Additionally, the Index Log API helps you retrieve search index logs for a web store.
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 full API functionality.

Before using the Search Settings APIs, make sure that your products are set up in the store.
Let’s assume a product wasn’t configured as searchable during its creation. 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:
| Resource | Supported HTTP Methods | Description | Available Version |
|---|---|---|---|
/commerce/management/webstores/{webstoreId}/search/product-settings | GET, PATCH | Specify whether a product is searchable or not. | 49.0 |
/commerce/management/webstores/{webstoreId}/search/attribute-settings/facetable-fields | GET, PUT | Get and update facetable attributes. | 49.0 |
/commerce/management/webstores/{webstoreId}/search/attribute-settings/searchable-fields | GET, PATCH | Get and update searchable attributes. | 49.0 |
/commerce/management/webstores/{webstoreId}/search/boost-bury-rules | GET, POST | Get all boost and bury rules for a web store. Create a boost and bury rule. You can create up to 25 boost and bury rules for a webstore. | 59.0 |
/commerce/management/webstores/{webstoreId}/search/boost-bury-rules/ruleId | DELETE, GET | Get a boost and bury rule. Delete a boost and bury rule. | 59.0 |
/commerce/management/webstores/{webstoreId}/search/results-rules | GET, PUT, POST | Create or retrieve search include rules for a web store. You can create up to 50 rules for a web store. | 58.0 |
/commerce/management/webstores/{webstoreId}/search/results-rules/ruleId | DELETE, PUT | Create or delete a search include rule for a web store. | 66.0 |
/commerce/management/webstores/{webstoreId}/search/indexes | GET, POST | Get indexes and create an index of a product catalog. | 49.0 |
/commerce/management/webstores/{webstoreId}/search/indexes/{indexId} | GET | Get and delete a search index. | 49.0 |
/commerce/management/webstores/{webstoreId}/search/index-logs | GET | Get search index logs for a web store. | 57.0 |
/commerce/management/webstores/{webstoreId}/search/sort-rules | GET, PUT | Create or retrieve sort rules for a web store. | 54.0 |
/commerce/management/webstores/{webstoreId}/search/suggestions | GET | Get suggestions for product searches. | 52.0 |
/commerce/management/webstores/{webstoreId}/search/products | GET | Search products. | 58.0 |
/commerce/management/webstores/{webstoreId}/search/product-search | POST | Search products. | 49.0 |