Search URL parameters and the predictive search URL

Every parameter the Shopify /search page accepts (q, type, options[prefix], options[unavailable_products], sort_by, page) and the /search/suggest.json endpoint.

Search page
/search?q=<terms>&type=product
Predictive
/search/suggest.json?q=<terms>
Sort
relevance, price-ascending, price-descending
Plan
Every plan
Last checked

In short

Shopify’s /search page takes q plus optional parameters: type=product,page,article limits result types, options[unavailable_products]=show|hide|last places sold-out items, options[prefix]=last matches partial words in pages and articles, sort_by=price-ascending sorts and page paginates. Predictive search answers at /search/suggest.json?q=… with up to 10 results per type. Put the parameters in hidden form inputs to change how your theme’s search behaves.

How to use it

  1. Try the parameters directly: /search?q=snow&type=product&options[unavailable_products]=hide.
  2. In the theme’s search form, add hidden inputs for type and the options you want; only q needs a visible field.
  3. Use routes.search_url as the form action so multi-language stores keep the language.
  4. For a dropdown as the customer types, call /search/suggest.json (or /search/suggest with section_id for HTML).

Code

search-form.liquid
{%- comment -%}
  A products-only search form that hides sold-out products.
  routes.search_url keeps the market's language path (/fr/search).
  Only q needs user input; the rest are hidden inputs.
{%- endcomment -%}
<form action="{{ routes.search_url }}" role="search">
  <label for="SearchProducts">Search products</label>
  <input id="SearchProducts" type="search" name="q" value="{{ search.terms | escape }}">
  <input type="hidden" name="type" value="product">
  <input type="hidden" name="options[unavailable_products]" value="hide">
  <button type="submit">Search</button>
</form>
urls.txt
# Search page: /search with q and optional parameters
https://your-store.com/search?q=snow
https://your-store.com/search?q=snow&type=product
https://your-store.com/search?q=snow&type=product,page&options[unavailable_products]=hide&options[prefix]=last
https://your-store.com/search?q=snow&type=product&sort_by=price-ascending
https://your-store.com/search?q=snow&page=2

# Parameters
q                               the search terms (required)
type                            product, page, article (comma-separated; default all)
options[unavailable_products]   show | hide | last (default last)
options[prefix]                 last | none (pages and articles only; products match partial words anyway)
sort_by                         relevance | price-ascending | price-descending
page                            results page, default 1

# Predictive search (JSON), up to 10 results per type
https://your-store.com/search/suggest.json?q=bag&resources[type]=product,collection&resources[limit]=4

# Storefront filters work on search results too
https://your-store.com/search?q=snow&type=product&filter.v.availability=1

Written by Lintel. MIT license: free to use in your own store and in client work.

Limits and edge cases

  • Products match partial words automatically; options[prefix] only changes page and article results.
  • Storefront search doesn’t support range queries like price:>50; use price filters (filter.v.price.gte) instead.
  • Defaults for type and unavailable products can also be changed in the Search & Discovery app’s settings.
  • Products hidden with the seo.hidden metafield or set to Unlisted don’t appear in search or predictive search.

Questions

How do I make Shopify search show only products?
Add type=product to the search URL, or a hidden input name="type" value="product" to the search form.
How do I hide sold-out products in Shopify search?
Add options[unavailable_products]=hide, or set it as the default in the Search & Discovery app.
What is the Shopify predictive search URL?
/search/suggest.json?q=<terms>, with resources[type] and resources[limit] to choose result types and count (1–10).
Can I sort Shopify search results by price?
Yes: sort_by=price-ascending or price-descending. Non-product results move to the end.
  • Checked on a Shopify store on the date shown. Shopify changes its admin often; if a step looks different, the idea usually still works.
  • Examples use placeholder IDs and your-store.myshopify.com. Replace them with your own.
  • MIT license for the code snippets.

Need this built, tested and maintained for your store? See Shopify development.

Have something to build? Let’s talk it through.

Taking a limited number of projects at a time. Every brief is read by an engineer, not a salesperson.

Gencer KarakayaShopify Engineer

An engineer reads your brief, and we reply by email.