Loading...

Turn fields into filters

Every rail down the side of the finished storefront — brand, category, colour, price, rating, availability — is a facet: a field visitors filter by instead of searching inside.

Make each field a facet

On the products list, choose Fields then Add Facet Field, and add each filter field with the type that makes filtering behave sensibly: brand, category and color as String, price and rating as Number, in_stock as Boolean. (If your import already created them as facets, they'll be listed here — this dialog is how you add or adjust them.)

The Add Facet dialog on the products list: the name 'brand' entered and a type of String, Number, Date or Boolean to choose

The type can't be changed once values are saved — a price filtered as text would sort "$9" above "$80", so it's worth getting right here.

Filter a search

With facets in place, a search takes a filter. This is "Apex gear under $150":

GET https://api.searchstack.dev/search/Demo/products/1?query=&filter=brand eq 'Apex' and price lt 150
X-API-Key: {your key}

Text values go in quotes, numbers don't, and clauses combine with and, or and not — the same small grammar every lesson's search uses.

List a facet's values

To build the rails themselves you need to know which values exist. Ask for a facet's distinct values directly:

GET https://api.searchstack.dev/facet/Demo/products/1/brand
X-API-Key: {your key}
["Apex", "Hearth", "Loomwear", "Lumina", "Nimbus", "NorthPeak"]

Go deeper: Facet types and the full filter grammar in the reference.

Top