Skip to content

productSearch

Queryin Catalog

Search for products with advanced filtering, sorting, and pagination capabilities

Arguments

ArgumentTypeDescription
categoryIdString
pageInt!Default 1
pageSizeInt!Default 20
searchTermString
sortProductSortOrderType!
filters[FacetFilterInput!]Default []
prefilters[FilterConditionInput!]Default []
exactSearchTermBooleanSearch searchTerm as typed, without correcting its spelling, for the shopper who asks for exactly that.Default false

Returns

ProductsResult!

FieldTypeDescription
items[Product!]!List of products in the result
paginationPagination!Where this page sits within the full result set
facets[Facet!]Available facets for filtering
queryIdStringThe search engine's id for this search, for click and conversion analytics that attribute an event to the search it came from. Null where the engine issues none, or analytics is not enabled for it.
correctedSearchTermStringThe term the products were found for, where the term as typed found nothing and the engine's top suggestion did. Null when the term was searched as given, and always null with exactSearchTerm.
redirectSearchRedirectWhere one of the engine's keyword rules sends this search term instead of to a result page. Null where the engine has no matching rule.

Example

query {
productSearch(
searchTerm: "laptop"
categoryId: "cat-electronics"
page: 1
pageSize: 24
sort: PRICE_ASCENDING
filters: [
{ key: "price", min: 500, max: 2000 },
{ key: "brand", selections: ["Apple", "Dell"] }
]
) {
pagination {
totalCount
hasNextPage
}
items {
id
slug
name
variant {
id
sku
price {
gross {
centAmount
currency
}
}
}
}
facets {
... on RangeFacet {
key
label
min
max
}
... on OptionsFacet {
key
label
options {
key
label
count
}
}
}
}
}

The query is the example the schema documents. The response shows its shape with placeholder values.

Served by

@evolve-framework/commercetoolsResolved
@evolve-framework/medusaResolved
@evolve-framework/sfccResolved

Used by

The storefront packages that send it, in these GraphQL documents: