getDiscountsByVectorSearch
Search discounts by meaning (semantic vector search).
Description
Searches discounts by meaning rather than exact keywords, using a natural-language query. Resolves to an IVectorSearchResponse<IDiscountsResponse>: the discounts are in items, the count in total.
When indexReady is false, the search index for this entity and language isn't built yet, so empty items don't mean that nothing matched.
.getDiscountsByVectorSearch(
,
,
,
);
Parameters schema
Schema
body(required): IDiscountsVectorSearch
Vector search parameters.
example:
{ queryText: "winter sale" }
body.queryText(required): string
Natural-language search query.
example: "winter sale"
body.vectorDistanceThreshold: number
Override of the cosine distance threshold (0..2).
example: 0.3
body.maxHits: number
Number of top candidates fetched before pagination. Default: 100. Maximum: 500.
example: 10
body.debug: boolean
Optional debug flag forwarded in the search body. It is not part of the API's VectorSearchDto and had no observed effect on the test stand (2026-11-14): distance is returned for every hit either way.
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 Discounts.getDiscountsByVectorSearch({ queryText: 'winter sale' });
Example with optional parameters
const response = await Discounts.getDiscountsByVectorSearch(
{
queryText: 'winter sale',
vectorDistanceThreshold: 0.3,
maxHits: 50,
},
'en_US',
0,
30,
);
Example response
{
"items": [],
"total": 0,
"indexReady": false
}
Response schema
Schema: IVectorSearchResponse<IDiscountsResponse>
items: IDiscountsEntity[]
Discounts in this response.
items.id: number
ID of the discount.
items.attributeSetId: number | null
ID of the attribute set linked to the discount, or null when no set is linked.
items.localizeInfos: ILocalizeInfo
Localized name of the discount.
items.version: number
Version number of the discount.
items.identifier: string
Marker of the discount.
items.type: IDiscountType
The type of the discount.
items.startDate: string
The start date of the discount.
items.endDate: string
End date of the discount.
items.discountValue: IDiscountValue
Discount value with its type and amount limits.
items.conditionLogic: string
How the conditions combine: AND or OR.
items.conditions: IDiscountCondition[]
Conditions of the discount.
items.exclusions: Record<string, unknown> | null
Exclusions of the discount.
items.gifts: Record<string, unknown> | null
Gifts of the discount.
items.giftsReplaceCartItems: boolean
Whether the gifts replace cart items.
items.userGroups: Record<string, unknown> | null
User groups the discount applies to.
items.userExclusions: Record<string, unknown> | null
Users excluded from the discount.
items.attributeValues: IAttributeValues
Attribute values of the discount.
items.attributeSetIdentifier: string
Marker of the attribute set.
items.bonusEvent: Record<string, unknown>
Bonus event configuration.
items.position: number
Position used for sorting.
example: 1
items.distance: number
Cosine distance to the query. Returned by the semantic (vector) search endpoint for every hit (measured on the SDK test stand, 2026-11-14; present regardless of the debug flag).
example: 0.12
total: number
Total number of discounts.
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.
Semantic search matches on meaning, not on the literal text. Keyword search with globalSearch() covers only products, pages, blocks and discounts.