Faceted search is a method of helping shoppers navigate a store’s product inventory by categorizing products into various categories, brands, product features, and more. Textual search is a method of retrieving products based on product fields, for example, product name and description. BigCommerce’s GraphQL Storefront API lets merchants on headless storefronts use faceted and textual search powered by results from our back-end search engine. These built-in capabilities also allow Stencil developers to take advantage of our search engine.
The GraphQL Storefront API’s faceted and textual search lets you create the following features:
You can access these features by querying the SearchProducts field. Note that you can query facets, filter by rating, or filter by “in-stock” only if the merchant is on a Pro or Enterprise plan. A merchant must enable product filtering for facets to be returned. In addition, only facets that a merchant marks as visible in their Product Filtering settings will be returned.
This page walks you through how to filter and query products and facets to display on your storefront. See the GraphQL Storefront Playground for full schema documentation.
To use faceted and textual search, specify a filter in the argument for SearchProducts. For faceted search, you can filter by price, rating, among other features and attributes of products. For textual search, use the searchTerm field.
These filters affect both the products and facets that are returned. For example, filtering by rating returns only products within the specified rating range and only facets that have products within the rating range.
See the GraphQL Storefront playground for descriptions of each filter.
All search queries automatically respect your store’s language settings if multi-language is enabled. See Multi-language Product Search.
To get products, specify products as a field in searchProducts. Here is an example request that returns the first two products with a rating between three and five:
You can sort the products that are returned using the sort field. Here is an example query that searches for products using a search term and sorts the returned products in alphabetical order:
The sort affects only the list of products returned. A merchant’s product filtering settings determine how facets are sorted.
If you sort by price, the products sort by either their salePrice or basePrice if sortPrice doesn’t exist.
For a list of product fields that searchTerm searches, see the Store Search Product Fields article.
The Storefront GraphQL API supports product search in multiple languages. When multi-language is enabled and translations are provided in the BigCommerce control panel, the API returns product names, descriptions, and search keywords in the shopper’s preferred language—determined by the Accept-Language HTTP header or customer settings.
Searchable fields include:
No special query arguments are required; localization is automatic based on the request context. If no language is supplied, the store’s default language is used.
BigCommerce supports a broad range of languages for multi-language search.
If an unsupported language code is passed in the request, the store’s default language (typically English) will be used.
If a translation is missing for a product’s content in the shopper’s selected language, the API automatically returns the “base” content (store’s default language) for those attributes. This ensures that products remain discoverable even when translations are incomplete.
Why this matters:
en-US for English, not en-US and en-GB); adding more than one can cause search results to be overwritten. If this occurs, remove extra locales and refresh your catalog.You can also search and filter to include only products that have a specific product attribute.
This GraphQL query is searching for products using a filter on a product attribute—specifically, filtering by the attribute Card Size with a value of Poker. It is also retrieving:
Category, Price, and Card Size.To get facets, specify filters as a field in searchProducts. Here is an example request that returns the specified facets that have products with a rating between three and five:
Note: The only facet query that works differently is ProductAttributeSearchFilter. To query names and information inside this filter, you must also query for the name one level above that node. If you do not format the query this way, the nodes will return empty.
For a complete list of facets, see the GraphQL Storefront playground.
In a product search, you can use AND and OR logic to control how multiple filters are applied:
These behaviors determine how flexible or strict your search is when using categoryIdsFilter. This is specifically useful when constructing Product Landing Pages (PLPs) or expecting a different filtering behavior.
This example filters products to only those that appear in both of the specified categories:
This example filters products to only those that appear in either of the specified categories:
To get both products and facets, specify both products and filters fields in searchProducts.
If a merchant has not enabled product filtering, you will receive an empty array for the returned facets, though products will still be returned: