getProductsByVectorSearch
Semantic (vector) search for products.
Description
This method performs a semantic (vector) search for products from a natural-language query - it matches on meaning rather than exact keywords. It returns a Promise that resolves to an array of IProductsEntity objects.
Products.getProductsByVectorSearch(
body*,
body.queryText*,
body.vectorDistanceThreshold,
body.maxHits,
body.debug,
langCode,
offset,
limit
);
Parameters schema
Schema
body(required): IVectorSearchProducts
Vector search body. Example: { queryText: "red running shoes" }
body.queryText(required): string
Natural-language search query.
example: "red running shoes"
body.vectorDistanceThreshold: number
Max vector distance for a hit.
example: 0.5
body.maxHits: number
Max number of hits to return.
example: 50
body.debug: boolean
Include debug info in the response.
example: false
langCode: string
Language code. Default: "en_US"
example: "en_US"
offset: number
Parameter for pagination. Default: 0
example: 0
limit: number
Parameter for pagination. Default: 30
example: 30
Examples
Minimal example
const response = await Products.getProductsByVectorSearch({ queryText: 'red running shoes' });
Example with attributes
const response = await Products.getProductsByVectorSearch(
{
queryText: 'red running shoes',
vectorDistanceThreshold: 0.5,
maxHits: 50,
},
'en_US',
0,
30,
);
Example response
[
{
"id": 1764,
"localizeInfos": {
"title": "Red running shoes"
},
"price": 100,
"additional": {
"prices": {
"min": 0,
"max": 100
}
},
"isVisible": true,
"isSync": true,
"sku": "0-123",
"attributeValues": {},
"attributeSetIdentifier": "my-set",
"statusIdentifier": "in_stock",
"statusLocalizeInfos": {
"title": "In stock"
},
"position": 1
}
]
Response schema
Schema: IProductsEntity[]
[]: IProductsEntity
A product entity.
[].id: number
The unique identifier.
example: 12345
[].localizeInfos: ILocalizeInfo
The localized name of the product.
example: { "title": "Red running shoes" }
[].price: number | null
The product page price taken from the index.
example: 100
[].sku: string | null
Product SKU (Stock Keeping Unit), may be null.
example: "SKU_12345"
[].attributeValues: IAttributeValues
Array of attribute values from the index.
[].statusIdentifier: string | null
Product page status identifier (may be null).
example: "in_stock"
[].isVisible: boolean
A sign of page visibility.
example: true
[].position: number
Item number (for sorting).
example: 1