Storefront search
Storefront search is based on query parameters that determine what information is returned to the customer in their search results.
Search URL structure
When you enter a search term in an online store, the page URL is updated to include information about your search. The basic URL structure for online store searches is:
/search?q=<query>
The following example shows a search URL that includes options based on the query parameters described below:
/search?q=snow&type=product,page&options[unavailable_products]=hide&options[prefix]=last
Query parameters
Search URLs contain the following query parameters.
Query parameter | Type | Description |
---|---|---|
q (required) |
String | The search query. |
type (optional) |
Comma-separated values | Specifies the type of results requested. Valid values: product , page , and article . Defaults to all types. |
page (optional) |
Integer | Specifies the current search results page. Defaults to 1 . |
options (optional) |
Hash | Specifies search options that you can customize with the unavailable_products and prefix settings. |
unavailable_products (optional) |
String | Specifies whether to display results for unavailable products. The three possible options are show , hide , and last . Set to last to display unavailable products below other matching results. Set to hide to exclude unavailable products from the search results. Default: last . |
prefix (optional) |
Comma-separated values | Specifies whether we want to perform a partial word match on the last search term. The possible options are none and last . Set to last to autocomplete the last term. For example, if a query is made on "winter snow", a search will be made on all resources that contain both the term "winter" as well as a term that starts with "snow" such as "snow", "snowshoe", or "snowboard". When set to none , the search will not autocomplete on the last term. Default: none . |