Product projections can be retrieved using full-text search, filtering, and faceting.
This endpoint provides high performance search queries over ProductProjections and is typically used to build Storefront Search functionalities that improve the discoverability of products for your customers. To optimize the usage of this endpoint for your project, check our performance tips.
Retrieving tailored product data is not supported by Product Projection Search. For such a scenario, use the Get ProductProjection in Store endpoints.
The API does not support filtering, faceting and sorting for Standalone Prices.
Existing filters, faceting, and sorting options will still work, but will only consider Embedded Prices, therefore using these options on Products with Standalone
ProductPriceMode might yield inconsistent results.
Activation of the feature
The Product Projection Search API is not active for the Project by default. If the feature is deactivated for your Project, the Product Projection Search endpoint returns a SearchDeactivated error.
To activate the feature for your Project, choose one of the following options:
- using the Merchant Center by navigating to Settings > Projects Settings > Storefront search.
- using the Change Product Search Indexing Enabled update action with
mode: ProductProjectionsSearch
on the Update Project endpoint.
{
"action": "changeProductSearchIndexingEnabled",
"enabled": true,
"mode": "ProductProjectionsSearch"
}
As soon as the feature is activated for your Project, its Products get indexed, and the Product Projection Search API as well as the Product Suggestions API will become fully functional soon after.
Automatic deactivation
The Product Projection Search API and the Product Suggestions API will be deactivated for a Project automatically if there have been no calls to them for the duration of 30 consecutive days. The APIs can be reactivated again as described above.
Product Projection Search
Use Product Projection Search to retrieve Product Projections matching full-text search, or filter criteria, and to let the API calculate facets about product information. Perform API calls either with GET or with POST.
with GET
This method appends query parameters to the URL. The maximum allowed URL length is 8192 characters. Exceeding this limit will result in URL truncation, potentially leading to unexpected results. For funnel searches on Product Listing Pages, where users select multiple filters, we recommend the POST method which passes the query parameters within the request body, avoiding URL length restrictions.
view_products:{projectKey}
view_published_products:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
markMatchingVariants Boolean | Set to Default: false |
text.<locale> String | The text to analyze and search for, for example as supplied by a user through a search input field. The parameter must include the language in form of a Locale. The content to search in, that means the full-text search, is only performed in the localized Product content of the specified language. The parameter can be passed multiple times. |
fuzzy Boolean | Set to Default: false |
fuzzyLevel Int | Set this parameter to overwrite the default fuzzy level.
Only applicable if
If the provided value exceeds the default value, the API responds with an InvalidInput error. |
filter.query String | Applies a filter to the query results before facets are calculated.
This parameter has an impact on facet counts.
If you don't use the The parameter can be passed multiple times. |
filter String | Applies a filter to the query results after facets are calculated.
This parameter does not have an impact on facet counts.
Use this parameter in combination with the The parameter can be passed multiple times. |
facet String | Requests calculation of facets. The parameter can be passed multiple times. |
filter.facets String | Applies a filter to the calculated facet results, not to the Products returned with the query results.
A facet's own aggregation is not filtered by its corresponding The parameter can be passed multiple times. |
sort String | Controls sorting of results. Use this parameter multiple times to sort by multiple fields.
The parameter can be passed multiple times. |
expand String | Enables server-side expansion of References. For details, see Reference Expansion. The parameter can be passed multiple times. |
limit Int | The maximum number of results returned on a page. Default: 20 |
offset Int | The starting point for retrieving paginated results. Default: 0 |
staged Boolean | Whether to search in the current or staged Product Projections. For API Clients with the Default: false |
priceCurrency | Enables Product price selection and Scoped Price Search. |
priceCountry | Enables Product price selection and Scoped Price Search.
It can be used only in conjunction with the |
priceCustomerGroup String |
|
priceCustomerGroupAssignments String | IDs of existing CustomerGroups used for Product price selection, when using multiple Customer Groups.
It can be used only in conjunction with the The parameter can be passed multiple times. |
priceChannel String |
|
localeProjection | Use for locale-based projection. The parameter can be passed multiple times. |
storeProjection String |
|
ProductProjectionPagedSearchResponse
asapplication/json
curl --get https://api.{region}.commercetools.com/{projectKey}/product-projections/search -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
{
"offset": 0,
"count": 2,
"total": 2,
"limit": 0,
"results": [
{
"id": "080feded-4f74-4d31-9309-f7ef6b7f1279",
"version": 3,
"productType": {
"typeId": "product-type",
"id": "1c095f1b-e638-4c7e-86c4-c58df873fca6"
},
"name": {
"en": "Some Products"
},
"categories": [],
"slug": {
"en": "product_slug_jxeutnxwkswk"
},
"masterVariant": {
"id": 1,
"prices": [],
"images": [],
"attributes": [
{
"name": "text1",
"value": {
"it": "italian1",
"de": "german1",
"en": "englisch1"
}
}
]
},
"variants": [],
"searchKeywords": {
},
"hasStagedChanges": false,
"published": true,
"createdAt": "1970-01-01T00:00:00.001Z",
"lastModifiedAt": "2014-01-07T15:25:50.034Z"
},
{
"id": "e779ec1a-0a98-4135-8344-d51bdafd4fe6",
"version": 6,
"productType": {
"typeId": "product-type",
"id": "bac5ef74-e0f9-4792-8439-ab84b270599e"
},
"name": {
"en": "product with dates"
},
"description": {
"en": "<p>Used to test the various date attributes<br></p>"
},
"categories": [],
"slug": {
"aa": "product-with-dates-1432797256269",
"de": "product-with-dates-1432797256269",
"en": "product-with-dates-1432797256269"
},
"masterVariant": {
"id": 1,
"prices": [],
"images": [],
"attributes": [
{
"name": "aboolean",
"value": true
}
]
},
"variants": [],
"searchKeywords": {
},
"hasStagedChanges": true,
"published": true,
"createdAt": "2015-05-28T07:15:48.738Z",
"lastModifiedAt": "2015-05-28T07:19:38.624Z"
}
],
"facets": {
"red-things": {
"type": "filter",
"count": 0
},
"variants.attributes.size": {
"type": "terms",
"dataType": "text",
"missing": 0,
"total": 2,
"other": 0,
"terms": [
{
"term": "40",
"count": 2
},
{
"term": "41",
"count": 2
}
]
},
"variants.attributes.price": {
"type": "range",
"ranges": [
{
"from": 0,
"fromStr": "0",
"to": 100,
"toStr": "100",
"count": 2,
"total": 2,
"min": 0,
"max": 100,
"mean": 50.5
}
]
}
}
}
with POST
For implementing funnel search on Product Listing Pages where users select multiple filters, use this POST method. To avoid URL length restrictions, this method passes the same query parameters as defined in the GET method, within the request body in URL-encoded format.
view_products:{projectKey}
view_published_products:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
application/x-www-form-urlencoded
ProductProjectionPagedSearchResponse
asapplication/json
Search response
The response returned to a Product Projection Search request. The object contains the query results with Product Projections where at least one ProductVariant matches the search query, as well as the facet results, if requested.
limit Int | The maximum number of results returned on a page. Default:20 Minimum: 0 Maximum: 500 |
offset Int | The starting point for the retrieved paginated result. Default:0 Minimum: 0 Maximum: 10000 |
count Int | Actual number of results returned. |
total Int | Total number of results matching the query. |
results Array of ProductProjection | ProductProjections where at least one ProductVariant matches the search query, provided with the |
facets | Facet results for each facet expression specified in the search request. Only present if at least one |
Query results
The results
array contains Product Projections where at least one ProductVariant matches the full-text search query or the provided filter expression.
The result can include Product Variants that do not match the search query.
We recommend setting the query parameter markMatchingVariants=true
to mark the matching variants.
Facet results
Each facet expression specified in the search request contains a corresponding facet result in the facets
object of the query result. The corresponding results for term, range, and filtered facets are term facet result, range facet result, and filtered facet result respectively.
By default, facet results provide a count of ProductVariants. An additional count of Products can be requested through the counting products extension. A facet result can be accessed by its attribute path or, if provided in the facet expression, by its alias.
variants.attributes.color:red as red-things
variants.attributes.size:"m"
{
"offset": 0,
"count": 0,
"results": [],
"facets": {
"red-things": {
"type": "filter",
"count": 0
},
"variants.attributes.size": {
"type": "filter",
"count": 0
}
}
}
Term facet result
type FacetTypes | terms |
dataType | Data type to which the facet is applied. |
missing Int | Number of ProductVariants that have no value for the specified term facet expression. |
total Int | Number of terms matching the term facet expression.
|
other Int | Number of terms not represented in this object (such as the number of terms beyond the limit). |
terms Array of FacetTerm | Values for the field specified in term facet expression for which at least one ProductVariant could be found. By default, facet terms are returned in a descending order of their If the term facet expression specifies to count Products through the 200 |
TermFacetResultType
Data type to which the facet is applied.
text
For AttributeTextType Attributes.
date
For AttributeDateType Attributes.
time
For AttributeTimeType Attributes.
datetime
For AttributeDateTimeType Attributes.
boolean
For AttributeBooleanType Attributes.
number
For AttributeNumberType Attributes.
FacetTerm
term Any | Value for the field specified in the term facet expression for which at least one ProductVariant could be found. |
count Int | Number of ProductVariants for which the |
productCount Int |
Range facet result
type FacetTypes | range |
ranges Array of FacetRange | Statistical data over values for |
FacetRange
from Float | The range's lower endpoint.
|
fromStr String | The range's lower endpoint. An empty string represents -∞. |
to Float | The range's upper endpoint.
|
toStr String | The range's upper endpoint. An empty string represents +∞. |
count Int | Number of ProductVariants for which the values in a field fall into the specified range. |
productCount Int | |
total Float | Sum of all values contained in the range. |
min Float | Minimum value within the range. |
max Float | Maximum value within the range. |
mean Float | Arithmetic mean of the values within the range. |
Filtered facet result
type FacetTypes | filter |
count Int | Number of ProductVariants matching the value specified in filtered facet expression. |
productCount Int | Number of Products matching the value specified in filtered facet expression. Present only if the |
Matching variants
For filters on searchable fields that refer to the Product as a whole (for example, categories
, key
, slug
), all variants of the Product Projections returned in the search response match the filter by default.
For filters on Product Variant-specific searchable fields, (for example, variants.attributes.{name}
, variants.prices.centAmount
), the filter may match only for certain Product Variants.
To find out which of the Product Variants match the search query, we recommend setting markMatchingVariants
to true
in the Product Projection Search request.
This will cause the ProductVariants to include the isMatchingVariant
field indicating which Product Variant matches the query.
- If
isMatchingVariant: true
, the Product Variant matches the search query. - If
isMatchingVariant: false
, the Product Variant does not match the search query, but is returned as part of the returned Product Projection.
If markMatchingVariants
is set to false
in the Product Projection Search request, the Product Variants returned in the Product Projection Search response will not contain the isMatchingVariant
field.
Full-text search
The text.{language}
query parameter performs a full-text search on the ProductProjections data.
For localized fields, the API only searches text matching the language specified in the text.{language}
query parameter.
Search results are based on the first 256
characters provided with the text.{language}
query parameter, and characters beyond this limit are ignored. The API will not return an error when you pass longer values for this query parameter.
Searchable fields
By default, the API indexes the following standard fields of a ProductProjection for full-text search:
name
(weighed heavier than the other searchable fields)description
slug
sku
searchKeywords
metaKeywords
and metaTitle
are not indexed for full-text search.
The Attributes on Product Variants of following AttributeTypes are indexed for search if the AttributeDefinition's isSearchable
is set to true
:
- Text type Attributes
- Localizable text type Attributes
- Money type Attributes
- The
label
property of each enum value in an enum type Attribute. - The
label
property of each localized enum value in a localized enum type Attribute. - AttributesReferenceType: Attributes are not full-text searchable, but are available for filtering.
If no sort
query parameter is given in the Product Projection Search request, the results are sorted by the relevance of the Product to the search text passed.
Fuzzy search
If you set the fuzzy
query parameter in the Product Projection Search request to true
, the API will return ProductProjections that contain slight differences from the search text
.
For example, a fuzzy search for "whisky" will also return Products that are labeled with "whiskey."
To optimize the discovery of related terms, the API dynamically adapts the level of fuzziness applied on the text based on the length of the text to analyze.
0
- fortext
of one or two characters.1
- fortext
of three, four or five characters.2
- fortext
of more than five characters.
If you want to set the fuzzy level to a value different from these defaults, you can set it explicitly with the fuzzyLevel
query parameter.
However, the value must not exceed the default value, which is selected dynamically based on the length of the text
value.
The fuzziness level is quantified in terms of the Damerau-Levenshtein distance, which is the number of operations needed to transform one word into another.
Filters
In addition to full-text search, Product Projection Search allows you to filter search results for exact values in specified Product fields. This section describes which filter parameters exist and how you formulate filter expressions for specific searchable fields.
Filter parameters
To support multi-select faceting, the API allows for filtering products before and after calculating facets.
- The
filter.query
parameter filters Products in the query results before calculating facets. - The
filter
parameter filters Products in the query results after calculating facets. - The
filter.facets
parameter modifies the aggregated facet counts in the facet results, not the Products returned with the query results.
A facet's own aggregation is not filtered by its correspondingfilter.facets
criteria.
For example, if you're requesting two facets—one for color and another for size—and you applyfilter.facets
for color, the facet aggregation for size will be filtered accordingly, but the facet counts for color itself will remain unaffected.
This allows for multi-select faceting in combination with thefilter
parameter, where storefront users can refine search results across multiple facet values without limiting the overall query results.
However, not all filter expressions can be used with all filter parameters. For more information about which filter expression can be used with which filter parameter, see field-specific filters.
Filter expressions
You can specify filters with filter expressions made of searchable fields, filter operators, and values to search for.
Matching value
Filters of the form field:{value}
search for a specified value for the given field.
The value must match exactly.
If you want fuzzy search for text values, use full-text search instead.
Matching values
If you want to specify that the given field can have this or that value, you can specify them in the same filter parameter, separated by a comma (OR
operator).
For example, the below search request filters Products of the color "black" OR
"grey":
GET /{projectKey}/product-projections/search?filter%3Dvariants.attributes.color.key%3A%22black%22%2C%22grey%22
Within range of values
If you want to specify that the values for a given field should be in a certain range, you specify a range filter with its lower- and upper-bounds.
:range ({from} to {to})
You can specify multiple ranges for the same filter by separating the ranges by commas:
:range ({from} to {to}), ({from} to {to})
Use *
to ignore the lower- or upper-bound values: :range (* to {to})
Check if value exists
If you want to check if a specific field has a value assigned, but you don't really care about which value, you can use the filter expression of the form {field}:exists
.
Empty strings (""
) are recognized as existing values and are caught by this filter.
Check if value is missing
If you want to check if a specific field has no value assigned, you can use the filter expression of the form {field}:missing
.
Empty strings (""
) are not recognized as missing values and are not caught by this filter.
Combine filters with logical AND
You can specify that Products you search for should match filter X AND filter Y at the same time by passing multiple filter
parameters in one search request.
This combines them with an AND
operator.
For example, the below search request filters Products of a certain Category AND
of the color "black":
GET /{projectKey}/product-projections/search?filter%3Dcategories.id%3A%22{category-ID}%22%26filter%3Dvariants.attributes.color%3A%22black%22
Field-specific filters
This section describes the searchable fields on Products and Product Variants for which you can set filters.
Filter by Category
The following filters can be applied:
-
categories.id:"{id}"
filters Products that belong to the specified Category. -
categories:missing
filters Products that are not assigned to any Category.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
categories:exists
filters Products that are assigned to at least one Category.
This filter can be used with filter
, filter.query
, and filter.facets
parameters.
Filter by Category subtrees
The following filters can be applied:
categories.id: subtree("{id}")
filters Products that belong to the specified Category or any of its descendant Categories.categories.id: subtree("{id}"), subtree("{id2}")
filters Products that belong to different branches of the Category tree.
Othersubtree
functions can be added to the filter. Each subtree specifies the Category of the other branch in the Category tree.
The subtree
function can also be used in combination with several regular ID filters: categories.id: subtree("{id1}"), "{id2}", "{id3}"
. If the Categories are children of {id1}
, it is not necessary to specify {id2}
and {id3}
.
The subtree
function can be applied in filter.facets
.
Filter by Price
This filter only works with Embedded Prices.
If a Product Variant has several Embedded Prices, only the first Price is used for filtering. To use another Product Variant Price (selected based on the Price scope), use the Scoped Price filter.
The following filters can be applied:
-
variants.price.centAmount:{amount}
filters Products whose Embedded Price matches the specified value. -
variants.price.centAmount:range ({from} to {to}), ({from} to {to}), ...
filters Products whose Embedded Price matches the specified range that includes the lower- and upper-bound values. -
variants.price.centAmount:range (* to {to})
filters Products whose Embedded Price matches the specified range that includes the lower- and upper-bound values.
Using*
ignores the lower- or upper-bound values. -
variants.prices:missing
filters Products that contain a ProductVariant without any Embedded Price set.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
variants.prices:exists
filters Products that contain a ProductVariant with at least one Embedded Price set.
These filters can be used with filter
, filter.query
, and filter.facets
parameters.
Filter by Scoped Price
To filter Products by Scoped Price, use Scoped Price Search. Filter by price only works with Embedded Prices.
Scoped Price is a Price contained inside a ProductVariant selected based on the Price scope like currency, country, Channel, and Customer Group. This means that only those Product Variants with a Price matching all Price Selection Parameters contain the scopedPrice
field with the ScopedPrice. You can apply filters on the scopedPrice
field and its subfields like value
and currentValue
as described in this section.
These filters can be used with filter
, filter.query
, and filter.facets
parameters.
This filter only works with Embedded Prices.
Filter by ScopedPrice value
This filter only works with Embedded Prices.
Filters, facets, and sorts Products by the original Product Variant Embedded Price value.
For example: variants.scopedPrice.value.centAmount:range (* to 1200)
.
Filter by ScopedPrice currentValue
This filter only works with Embedded Prices.
Filters, facets, and sorts Products by the original Product Variant Embedded Price value or a discounted value, if available.
For example: variants.scopedPrice.currentValue.centAmount:1000
.
Filter by ScopedPrice discounted value
This filter only works with Embedded Prices.
Filters, facets, and sorts Products if an Embedded Price discounted
value is available.
For example: variants.scopedPrice.discounted.value.centAmount:range (* to 1200)
.
Filter by scopedPriceDiscounted
This filter only works with Embedded Prices.
Filters, facets, and sorts Products by the ProductVariant scopedPriceDiscounted
. The value would be true
if a ProductDiscount is applied on the Embedded Price.
Filter by SKU
The following filters can be applied:
-
variants.sku:{sku}
filters Products with a ProductVariant that matches the specifiedsku
. -
variants.sku:missing
filters Products that have a ProductVariant with nosku
set.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
variants.sku:exists
filters Products that have a ProductVariant with asku
set.
This filter can be used with the filter
and filter.query
parameters.
Filter by Product Key
The following filters can be applied:
Filter by ProductVariant Key
The following filters can be applied:
-
variants.key:{key}
filters Products that have a ProductVariant matching the specifiedkey
. -
variants.key:missing
filters Products that have a ProductVariant with nokey
set.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
variants.key:exists
filters Products that have a ProductVariant with akey
set.
Filter by ProductType
productType.id:{id}
filters Products that matches the specified ProductType.
This filter can be used with the filter
and filter.query
parameters.
Filter by TaxCategory
The following filters can be applied:
-
taxCategory.id:{id}
filters Products that match the specified TaxCategory. -
taxCategory:missing
filters Products that do not belong to any TaxCategory.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
taxCategory:exists
filters Products that have a TaxCategory set.
This filter can be used with the filter
and filter.query
parameters.
Filter by State
The following filters can be applied:
-
state.id:{id}
filters Products that match the specified State. -
state:missing
filters Products that do not belong to any State.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
state:exists
filters Products that have a State set.
This filter can be used with the filter
and filter.query
parameters.
Filter by reviewRatingStatistics
The following filters can be applied:
reviewRatingStatistics.averageRating:{value}
filters Products that have the average ReviewRatingStatistics matching the specified value.reviewRatingStatistics.averageRating:range ({from} to {to}), ({from} to {to}), ...
filters Products that have the average ReviewRatingStatistics matching the specified range that includes the lower- and upper-bound values. Using*
ignores the lower- or upper-bound values.reviewRatingStatistics.highestRating:{value}
filters Products that have the highest ReviewRatingStatistics matching the specified value.reviewRatingStatistics.highestRating:range ({from} to {to}), ({from} to {to}), ...
filters Products that have the highest ReviewRatingStatistics matching the specified range that includes the lower- and upper-bound values. Using*
ignores the lower- or upper-bound values.reviewRatingStatistics.lowestRating:{value}
: filters Products that have the lowest ReviewRatingStatistics matching the specified value.reviewRatingStatistics.lowestRating:range ({from} to {to}), ({from} to {to}), ...
: filters Products that have the lowest ReviewRatingStatistics matching the specified range that includes the lower- and upper-bound values. Using*
ignores the lower- or upper-bound values.reviewRatingStatistics.count:{value}
filters Products that have a number of ReviewRatingStatistics matching the specified value.reviewRatingStatistics.count:range ({from} to {to}), ({from} to {to}), ...
filters Products that have a number of ReviewRatingStatistics matching the specified range.
This filter can be used with the filter
and filter.query
parameters.
Filter by Attribute values
To filter by an Attribute value, the Attribute must have the isSearchable
field set to true
in its AttributeDefinition.
The following filters can be applied:
-
variants.attributes.{name}:"{value}"
filters ProductVariants with the Attribute matching the specified value. -
variants.attributes.{name}:range ({from} to {to}), ({from} to {to}), ...
filters ProductVariants with the Attribute matching the specified range that includes the lower- and upper-bound values. Using*
ignores the lower- or upper-bound values. -
variants.attributes.{name}:missing
filters Products that do not have a Attribute set.Empty strings (
""
) are not recognized as a missing value and are not caught by this filter. -
variants.attributes.{name}:exists
filters Products that have a Attribute set. -
For AttributeEnumType Attributes, the filter must be applied to the
key
of the AttributePlainEnumValue.variants.attributes.{myEnumName}.key:"{value}"
-
For AttributeMoneyType Attributes, the filter must be applied to Money
centAmount
orcurrencyCode
property.variants.attributes.{myMoneyAttribute}.centAmount:{value}
variants.attributes.{myMoneyAttribute}.centAmount:range ({from} to {to}), ({from} to {to}), ...
variants.attributes.{myMoneyAttribute}.currencyCode:"{value}"
-
For AttributeReferenceType Attributes, the filter must be applied to the
id
or thetypeId
of Reference.variants.attributes.{myReferenceAttribute}.id:"{id}"
variants.attributes.{myReferenceAttribute}.typeId:"{typeId}"
-
For AttributeSetType Attributes, the filter can be specified multiple times to search for a set that contains at least those values (
AND
). Specifying multiple values, separated by a comma, will match if one of those values is present in the set (OR
).
For example, the below search request filters Products of the color "green"AND
"black"OR
"grey":GET /{projectKey}/product-projections/search?filter%3Dvariants.attributes.colors%3A%22green%22%26filter%3Dvariants.attributes.colors%3A%22black%22%2C%22grey%22
These filters can be used with the filter
, filter.query
, and filter.facets
parameters.
Filter by Product Variant availability
The following filters can be applied:
variants.availability.isOnStock:true
filters ProductVariants with the availability matching the specified value.variants.availability.availableQuantity:range (1 to *)
filters ProductVariants with the availability matching the specified range that includes the lower- and upper-bound values. Using*
ignores the lower- or upper-bound values.variants.availability.channels.<channel-id>.isOnStock:true
filters ProductVariants in a specific supply Channel with the availability matching the specified value.variants.availability.channels.<channel-id>.availableQuantity:range (1 to *)
filters ProductVariants in a specific supply Channel with the availability matching the specified range that includes the lower- and upper-bound values. Using*
ignores the lower- or upper-bound values.variants.availability.isOnStockInChannels:"channel-id-1","channel-id-2","channel-id-3"
filters ProductVariants where ProductVariantAvailabilityisOnStock
istrue
in at least one of the specified Channels.
Filter by Product searchKeywords
searchKeywords.{language}.text:"{value}"
filters Products that matches the search keywords in a specified locale.
Filter by DateTime
Filters ProductVariants created or updated within the specified DateTime range.
Filter by createdAt
createdAt:range ({from} to {to})
filters ProductVariants by the createdAt
date in a specific date range. For example:
GET /{projectKey}/product-projections/search?filter.query%3DcreatedAt%3Arange%20(%222015-06-04T12%3A27%3A55.344Z%22%20to%20%222016-06-04T12%3A27%3A55.344Z%22)
The search result includes the lower- and upper-bound values. Using *
ignores the lower- or upper-bound values.
Filter by lastModifiedAt
lastModifiedAt:range ({from} to {to})
filters ProductVariants by the lastModifiedAt
date in a specific date range.
The search result includes the lower- and upper-bound values. Using *
ignores the lower- or upper-bound values.
Facets
Facets calculate statistical counts to aid in faceted navigation. It answers questions like "how many t-shirts of size XL are there?" or "how many TVs are there that cost between US$500 and $600?"
The first question is answered by a filtered facet, and the second one by a range facet. If you want to know how many t-shirts are there for each of the sizes, request a term facet for the size attribute.
Facet calculation is requested by providing a facet expression through the facet
query parameter in a Product Projection Search API call.
Each type of facet has its specific facet expression:
- term facet expression for term facets,
- range facet expression for range facets, and
- filtered facet expression for filtered facets.
Optionally, extend the facet expression with alias or counting products parameters.
Find the calculated facets in the facet results.
To facet by an Attribute value, the Attribute must have the isSearchable
field set to true
in its AttributeDefinition.
Facets for prices only work with Embedded Prices. If you need faceting for StandalonePrices, use Product Search instead.
Term facets
This facet provides the counts for each of the different values the query parameter has. It is useful, for example, for obtaining all possible values of a Product Attribute to provide filters for those values on the frontend.
Term facet expression
To retrieve facet counts for all occurring values of a ProductVariant field, the following facets can be applied.
categories.id
counts Product Variants of all Categories.
Other built-in fields can be requested analogously.
Attributes
variants.attributes.{name}
counts Product Variants for all occurring values of custom simple value Attributes such astext
,date
,time
,datetime
,boolean
, andnumber
.variants.attributes.{name}.{lang}
counts Product Variants for all occurring values of customltext
Attributes in the given language.variants.attributes.{name}.key
counts Product Variants for all occurringenum
orlenum
Attribute keys.variants.attributes.{name}.label
counts Product Variants for all occurringenum
Attribute labels.variants.attributes.{name}.label.{lang}
counts Product Variants for all occurringlenum
Attribute labels in the given language.variants.attributes.{name}.centAmount
counts Product Variants for all occurring values of a custommoney
Attribute.variants.attributes.{name}.currencyCode
counts Product Variants for all occurring currency codes of a custommoney
Attribute.
The following example requests term facets for the Attributes color and size:
GET /{projectKey}/product-projections/search?facet%3Dvariants.attributes.colors%26facet%3Dvariants.attributes.size%3A%22m%22
Availability
variants.availability.availableQuantity
counts Product Variants for all occurring available quantities.variants.availability.channels.<channel-id>.availableQuantity
counts Product Variants for all occurring available quantities for the supply Channel with ID<channel-id>
.
Review ratings
reviewRatingStatistics.averageRating
counts Product Variants for all occurring average ratings.reviewRatingStatistics.highestRating
counts Product Variants for all occurring highest ratings.reviewRatingStatistics.lowestRating
counts Product Variants for all occurring lowest ratings.reviewRatingStatistics.count
counts Product Variants for all occurring Review ratings counts.
Range facets
This type counts ProductVariants for which the query value is a range (with minimum and maximum value) specified in the range facet expression, for example, from a Product's Embedded Prices to filter Products by price with a range slider.
Range facet expression
To aggregate facet counts across ranges of values, the range
qualifier can be applied analogous to the filters with its lower- and upper-bounds:
:range ({from} to {to})
You can specify multiple ranges for the same facet by separating the ranges by commas:
:range ({from} to {to}), ({from} to {to})
Use *
to ignore the lower- or upper-bound values: :range (* to {to})
The :range
notation is applicable to the date
, time
, datetime
, number
, and money
type fields. It is also applicable to a set
of these types. If one matching element is contained in the set
, all elements are used in the aggregation.
Ranges of Prices
variants.price.centAmount:range
counts Product Variants whose Embedded Price falls in one of the specified ranges.
variants.price.centAmount:range (* to 50), (50 to 100), (100 to *)
Ranges of Scoped Price
Can only be applied in combination with Scoped Price search.
variants.scopedPrice.currentValue.centAmount:range
counts Product Variants whose ScopedPricecurrentValue
falls in one of the specified ranges.
variants.scopedPrice.currentValue.centAmount:range (* to 1000), (1000 to 2000), (2000 to 3000)
Ranges of Money type Attributes
variants.attributes.{name}:range
counts Product Variants whose values of the Attribute fall in one of the specified ranges.
Filtered facets
This facet provides counts for specific values of ProductVariant fields.
Filtered facet expression
To get facet counts for a specific field value, the requested value can be appended after a colon. This notation can be applied to any kind of field analogous to the filters.
Categories
-
categories.id:"{id}"
counts Product Variants in the specified Category. -
categories.id: subtree("{id}")
counts Product Variants in the subtree of the specified Category. -
categories.id: subtree("{id1}"), subtree("{id2}")
counts Product Variants for each of the specified subtrees.Unlike filters, facets using
subtree
cannot be mixed with regular value facets, socategories.id: subtree("{id}"), "{id2}"
will ignore{id2}
. -
categories.id: subtree("*")
: The asterisk parameter is equivalent to counting the ProductVariants that have a Category assigned.
Prices
variants.price.centAmount:{amount}
counts Product Variants that have the specified Embedded Price.
Attributes
variants.attributes.{name}:{value}
counts Product Variants with the Attribute that match the specified value of a simple Attribute.String values must be set in quotation marks. Add the respective postfixes for other Attribute types analogous to when requesting facets for all values (see above).
variants.attributes.{name}:{value},{value2}
counts Product Variants with the Attribute that match at least one of the values in the comma-separated list.variants.attributes.{myEnumName}.key:"{value}"
counts the occurrences of a specific enum key.
Facet expression extensions
Alias
Optionally, you can give an alias to all facets that can be used instead of the Attribute path in the result. This makes it possible to calculate multiple facets on the same Attribute in the same search request.
Examples:
variants.attributes.color.key:red as red_stuff
variants.attributes.brand:"Coca-Cola" as brand_coke
variants.attributes.brand:"Pepsi" as brand_pepsi
variants.price.centAmount:range(0 to 9999) as price_below_100
variants.price.centAmount
Counting Products
In addition to ProductVariants, all facets can optionally count Products by appending counting products
to a facet expression.
The corresponding facet result then contains an additional field productCount
that shows the number of Products.
Examples:
-
variants.attributes.color.key counting products
returns a term facet result for each FacetTerm (in this case for each color) containing:- the number of ProductVariants with that color.
- the number of Products having at least one ProductVariant with that color.
-
variants.price.centAmount:range (0 to 10000) counting products
returns a range facet result for each FacetRange containing:- the number of ProductVariants having an Embedded Price in that FacetRange.
- the number of Products having at least one ProductVariant with an Embedded Price in that FacetRange.
-
variants.attributes.color.key:red counting products
returns a filtered facet result containing:- the number of ProductVariants that are red.
- the number of Products having at least one red ProductVariant.
-
categories.id:"{id}" counting products
returns a filtered facet result containing:- the number of Products in the specified Category.
- the sum of all ProductVariants of these Products.
Sorting
By default, search results are sorted in a descending order of relevance with respect to the provided text
(that is their "score"). An alternative sorting can be specified using the sort
parameter with the structure {field} {direction}
.
Compound sorting (also known as multi-sort) is applied when specifying multiple sort parameters ordered by priority with each parameter having its own sorting direction, ascending (asc
) or descending (desc
).
If the sort
parameters do not define an ordering, the position of some or all Products can be non-deterministic that is not predictable and repeatable across API requests.
Common cases are:
- When neither
text
norsort
is given, the complete order is non-deterministic. - When full text is provided but no
sort
is given, the results are returned in a descending order of relevance. - When Products have no value set on the fields that are the sort criteria, the position is non-deterministic among those with no value set.
- When Products have identical vales on the fields that are the sort criteria, the position among each group with identical values is non-deterministic.
To achieve a deterministic order, always have a sort
parameter at the end of the list of sort
parameters that sorts by a field or attribute that has distinct values across all products. For example, createdAt
or an Attribute specific for this purpose.
The following are standard fields to sort by:
name.{language}
Sorts Products by their name.
The field must include the language in the form of a Locale.categoryOrderHints.{category ID}
Sorts Products by their CategoryOrderHint in combination with a filter by category.createdAt
Sorts Products by their creation date.lastModifiedAt
Sorts Products by their last modification date.id
Sorts Products by their ID.score
Sorts Products by the search relevance score.
Sorting byscore
can be combined with other sorting criteria. For example, sorting byscore
andid
ensures consistent order of Products across several search requests for Products that have the same relevance score.
name.de asc
Sort by Price
The sorting only works with Embedded Prices.
price
sorts Products by their Embedded Price. Since Prices can vary across Variants of a Product, the highest Embedded Price is used for a descending sort direction, while the lowest Embedded Price is used for an ascending sort direction.
Only the centAmount
of the first Embedded Price from the prices of every ProductVariant is used for sorting. If you have more than one Embedded Price defined per Product Variant, consider sorting by Scoped Price.
Sort by Scoped Price
To sort Products by their Variant's scopedPrice
, use Scoped Price Search.
variants.scopedPrice.value
Sorts Products by their ScopedPricevalue
.variants.scopedPrice.currentValue
Sorts Products by their ScopedPricecurrentValue
.
Sorting by value
or currentValue
might return an unexpected result if you don't specify one of their subfields. For example, to sort by the numerical value of the Price, you must specify the .centAmount
subfield as follows: variants.scopedPrice.currentValue.centAmount
.
Since prices can vary across Variants of a single Product, the following behavior applies: When the sort direction is descending, the highest Embedded Price of a product is used for sorting. When the sort direction is ascending, the lowest Embedded Price is used.
This feature compares only Embedded Prices matching exactly the Price Selection Parameters given with the Scoped Price Search request and is therefore the safer option when there is more than one Price on a Product Variant compared to sorting by Price.
Sort by Reviews
The following sorts can be applied based on ReviewRatingStatistics:
reviewRatingStatistics.averageRating
Sorts Products by their average rating.reviewRatingStatistics.highestRating
Sorts Products by their highest rating.reviewRatingStatistics.lowestRating
Sorts Products by their lowest rating.reviewRatingStatistics.count
Sorts Products by the number of ratings.
Sort by values found on ProductVariants
If Products have several Product Variants, each Variant can have a different value on the sorted Attribute. You must specify whether the minimum or maximum value is to be used across the Variants to compare the Product with other Products.
By default, the minimum value is used when sorting in ascending order (asc.min
) and the maximum value is used when sorting in descending order (desc.max
). For a different sorting behavior, the parameters can be set to asc.max
or desc.min
respectively.
The field names to sort Products by values found on ProductVariants start with variants.
.
Sort by SKU
variants.sku
sorts Products sorted alphabetically by their SKUs.
Sort by availability
To sort products by availability:
variants.availability.restockableInDays
Sorts Products by number of days it takes to restock it (with no supply Channel).variants.availability.channels.<channel-id>.restockableInDays
Sorts Products by number of days it takes to restock it for a specific supply Channel.variants.availability.availableQuantity
Sorts Products by available quantity (with no supply Channel).variants.availability.channels.<channel-id>.availableQuantity
Sorts Products by available quantity for a specific supply Channel.
`variants.availability.availableQuantity desc.min`
Sort by Attributes
In addition to the sorting by the standard fields listed above, Products can also be sorted by their specific custom Attributes. The search endpoint only supports those Attributes that have been declared as searchable in the ProductType.
Attributes can only be sorted if the isSearchable
field is set to true
in its AttributeDefinition.
The following sort can be applied:
variants.attributes.{name}
Sorts Products by simple value Attributes such astext
,date
,time
,datetime
,boolean
, andnumber
.variants.attributes.{name}.{lang}
Sorts Products byltext
Attribute in the specified language.variants.attributes.{name}.key
Sorts Products byenum
orlenum
Attribute key.variants.attributes.{name}.label
Sorts Products byenum
Attribute label.variants.attributes.{name}.label.{lang}
Sorts Products bylenum
Attribute label in the specified language.variants.attributes.{name}.centAmount
Sorts Products bymoney
Attribute amount.variants.attributes.{name}.currencyCode
Sorts Products bymoney
Attribute currency.
variants.attributes.color.label.en asc.max
Pagination
A response to the search request contains the first 20 results by default.
Pagination allows you to retrieve the first 10 000
results by requesting them page by page.
The total
field in a query result indicates how many results match the search query in total.
Limit
With the limit
parameter you can set the maximum number of results returned on a page.
Any value between 0
and 100
is allowed, the default limit is 20
.
Set limit=0
if you want to retrieve facets
only, but not the search result.
Offset
The offset
parameter controls the starting point for retrieving paginated results.
With the default value 0
you retrieve the first page of query results.
Setting offset=1
skips the first page and returns the second page of results, and so on.
Each page contains a number of results defined by the limit
parameter.
The maximum allowed offset
is 10 000
.
Setting pagination parameters exceeding this limit will result in an error with the code "SearchExecutionFailure."