Skip to main content

getProductsByVectorSearch

Find products by meaning with a semantic (vector) search.

Description​

Runs a semantic (vector) search for products from a natural-language query, matching on meaning rather than exact keywords. Resolves to an IVectorSearchResponse<IProductsResponse>, not an array: the products are in items, the count in total, and indexReady says whether the search index is built.

When indexReady is false, the index for this entity and language isn't built yet: the query wasn't embedded, and empty items don't mean that nothing matched.

.getProductsByVectorSearch(

, , ,

);

Parameters schema​

Schema

body(required): IVectorSearchProducts
Vector search parameters.
example:

{ queryText: "red running shoes" }

body.queryText(required): string
Natural-language search query.
example: "red running shoes"

body.vectorDistanceThreshold: number
Maximum cosine distance for a match, from 0 (identical) to 2. Lower values are stricter. Default: the server setting, 0.18 unless changed.
example: 0.5

body.maxHits: number
Maximum number of nearest candidates to consider before offset and limit are applied; total never exceeds it. Default: 100, maximum: 500.
example: 50

body.debug: boolean
Deprecated and ignored: the API no longer reads debug and returns distance on every item.
example: false

langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"

offset: number
Number of records to skip. Default: 0. offset + limit must not exceed 200; a larger window is rejected with 400.
example: 0

limit: number
Maximum number of records to return. Default: 30.
example: 30

Examples​

Minimal example​

const response = await Products.getProductsByVectorSearch({ queryText: 'red running shoes' });

Example with all parameters​

const response = await Products.getProductsByVectorSearch(
{
queryText: 'red running shoes',
vectorDistanceThreshold: 0.5,
maxHits: 50,
},
'en_US',
0,
30,
);

Example response​

{
"items": [
{
"id": 2957,
"localizeInfos": {
"title": "Cosmo"
},
"isVisible": true,
"isSync": false,
"sku": null,
"price": 150,
"additional": {
"prices": {
"min": 51,
"max": 180
}
},
"categories": [
"catalog"
],
"statusIdentifier": "sale",
"statusLocalizeInfos": {
"title": "Sale"
},
"templateIdentifier": null,
"shortDescTemplateIdentifier": null,
"attributeValues": {
"product-name": {
"type": "string",
"value": "Cosmo",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"price": {
"type": "integer",
"value": 150,
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"currency_products": {
"type": "string",
"value": "USD",
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": false
},
"img": {
"type": "image",
"value": "",
"isIcon": false,
"position": 3,
"additionalFields": {},
"isProductPreview": true
}
},
"attributeSetIdentifier": "products",
"isPositionLocked": false,
"rating": {},
"paymentStages": null,
"moduleFormConfigs": [
{
"id": 12,
"formIdentifier": "review",
"moduleIdentifier": "catalog",
"isGlobal": false,
"isClosed": false,
"isModerate": false,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"entityIdentifiers": [
{
"id": "catalog",
"isNested": true
}
],
"formDataCount": 823,
"ratingCalculation": "average",
"allowHalfRatings": null,
"showAggregatedRating": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"2954": 823
},
"nestedEntityIdentifiers": [
"catalog"
],
"exceptionIds": []
}
],
"discountConfig": {},
"distance": 0.11743874057762116
}
],
"total": 1,
"indexReady": true
}

Response schema​

Schema: IVectorSearchResponse<IProductsResponse>

total: number
Total number of products found.
example: 100

items: IProductsEntity[]
Products in this response.
example:

[
{
"id": 12345,
"title": "Product 1"
},
{
"id": 67890,
"title": "Product 2"
}
]

items.id: number
ID of the product.
example: 12345

items.localizeInfos: ILocalizeInfo
Localized product data, such as the title.
example:

{}

items.statusIdentifier: string | null
Marker of the product status, or null.
example: "in_stock"

items.statusLocalizeInfos: ILocalizeInfo
Localized status name for the product.
example:

{ "title": "Sale" }

items.attributeSetIdentifier: string | null
Marker of the attribute set, or null if none is assigned.
example: "set_12345"

items.position: number
Position used for sorting. Present on catalog/list/ids//blocks entities; absent from vector (semantic) search results, so typed optional.
example: 1

items.price: number | null
Product price from the search index.
example: 150.00

items.additional: object
Extra values computed by the search index, such as the price range in prices.min and prices.max.
example:

{
"prices": {
"min": 5,
"max": 150
}
}

items.sku: string | null
Product SKU from the search index, or null.
example: "SKU_12345"

items.isSync: boolean
Whether the product's attribute index is up to date for the requested language. When false, an empty or partial attributeValues means the values are not published yet, not that there are none.
example: true

items.attributeValues: IAttributeValues
Attribute values keyed by attribute marker (an object, not an array).
example:

{
"product-name": {
"type": "string",
"value": "Split",
"position": 0
},
"price": {
"type": "integer",
"value": 150,
"position": 1
}
}

items.categories: string[]
URLs of the catalog pages the product belongs to.
example:

[
"catalog"
]

items.isVisible: boolean
Whether the product is visible.
example: true

items.moduleFormConfigs: Array<IFormConfig>
Form configurations of the module.

items.rating: IRating
Rating data: average value, likes and dislikes, and the calculation method.

items.isPositionLocked: boolean
Whether the sorting position is locked.
example: false

items.relatedIds: number[]
IDs of related products.
example:

[
12345,
67890
]

items.paymentStages: unknown
Payment stages of the product: an array of { title, value, marker } objects, or null when none are set.
example: null

items.distance: number
Relevance distance in vector (semantic) search. Present only in vector search results.
example: 0.42

items.discountConfig: Record<string, unknown>
Discount configuration.
example:

{}

items.templateIdentifier: string | null
Marker of the linked template.
example: "template_12345"

items.shortDescTemplateIdentifier: string | null
Marker of the template used for the short description.
example: "short_desc_template_12345"

items.signedPrice: string
Signed token (JWT) that fixes the product price for an order. Returned when signPrice is set.
see: Fixed product price
example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

items.productPages: IProductPageRef[]
Links between the product and the catalog pages it belongs to.
example:

[
{
"id": 16,
"pageId": 4,
"productId": 15,
"positionId": 244,
"categoryPath": "products"
}
]

items.blocks: string[]
Markers of the blocks shown on the product page (not the blocks whose selection includes the product).
example:

[
"block_12345",
"block_67890"
]

totalFound: number
Number of products matched before limits are applied; returned by block product endpoints (similarProducts, cart/wishlist recommendations, frequently ordered). Optional.
example: 2

indexReady: boolean
false when no vectors are built yet for this entity and language: the query was not embedded, so empty items do not mean that nothing matched. true means the result comes from a real search.

This method can't request price fixing, so its response has no signedPrice. To get one, call getProductsByIds() or a listing method with signPrice set. See Fixing the price (signPrice).