The search object
search object has the following attributes:
relevance, which is the default search sort order.
Returns an array of filter objects that have been set up on the search page.
Only returns filters relevant to the current search results. Filters will be empty for search results that contain over 1000 products.
true if an HTML form with the attribute
action="/search" was submitted successfully. This allows you to show content based on whether a search was performed.
Returns an array of matching search result items. The items in the array can be a(n):
You can access the attributes of individual search results by looping through
Search results have an additional
object_type attribute which returns the type of each result. This is useful for identifying result types when outputting results.
Returns the number of results found.
Returns the sort order applied to the search query by the
sort_by URL parameter. If there's no
sort_by URL parameter, then the default value is
For example, given the following URL, the following input would lead to the following output:
Returns an array of sorting options for the search query.
For example, the following input would lead to the following output:
Each option has the following attributes:
The customer-facing label for the sort option, which can be edited by merchants in the language editor.
The value of the sort option to be assigned to the
sort_by property in a form submission.
Returns the string that was entered in the search input box.
Use the liquid highlight filter to apply a different style to any instances in the search results that match up with
search.terms. For example:
Returns an array of strings representing the types that the search was performed on. The items in the array can be any combination of
The search types can be seen in the URL parameters of the search page. For example, given the following URL, the following input would lead to the following output: