Class: KlevuResponseQueryObject
/ Exports / KlevuResponseQueryObject
Result object for each query. A storage for results. Can be used to fetch more data, send events etc.
• new KlevuResponseQueryObject(responseObject, query, func)
Name | Type |
---|---|
responseObject | |
query | |
func |
• Optional categoryMerchandisingClickEvent: (params: { categoryTitle: string ; override?: Partial<KlevuV1CategoryProductsView> ; productId: string ; variantId?: string }) => void
▸ (params): void
When query is categoryMerchandising this is available. It is used to send categoryMerchandising click events
Name | Type |
---|---|
params | Object |
params.categoryTitle | string |
params.override? | Partial<KlevuV1CategoryProductsView> |
params.productId | string |
params.variantId? | string |
void
• func: KlevuFetchFunctionReturnValue
Function used to create this query
• Optional getRedirects: () => Promise<KlevuKeywordUrlMap[]>
▸ (): Promise<KlevuKeywordUrlMap[]>
Fetches redirects for this query. This is available only for search queries
Promise<KlevuKeywordUrlMap[]>
• hooks: KlevuResultEventOnResult[] = []
Hooks that can be used to listen for events
• query: KlevuQueryResult
This query
• Optional recommendationBannerClickEvent: (params: { resolution: "desktop" | "mobile" }) => void
▸ (params): void
When there is a banner in the recommendation this is available. It is used to send recommendation banner click events
Name | Type |
---|---|
params | Object |
params.resolution | "desktop" | "mobile" |
void
• Optional recommendationClickEvent: (params: { override?: Partial<KlevuRecommendationsEventV2Data> ; productId: string ; variantId?: string }) => void
▸ (params): void
When query is recommendation this is available. It is used to send recommendation click events
Name | Type |
---|---|
params | Object |
params.override? | Partial<KlevuRecommendationsEventV2Data> |
params.productId | string |
params.variantId? | string |
void
• responseObject: KlevuResponseObject
Original request response that includes all queries
• Optional searchClickEvent: (params: { autoSendViewEvent?: boolean ; override?: Partial<V1SearchEvent> ; productId: string ; variantId?: string }) => void
▸ (params): void
When query is search this is available. It is used to send search click events
Name | Type |
---|---|
params | Object |
params.autoSendViewEvent? | boolean |
params.override? | Partial<V1SearchEvent> |
params.productId | string |
params.variantId? | string |
void
• get filters(): undefined | (KlevuFilterResultOptions | KlevuFilterResultSlider | KlevuFilterResultRating)[]
All filters related to this query
undefined | (KlevuFilterResultOptions | KlevuFilterResultSlider | KlevuFilterResultRating)[]
• get functionParams(): undefined | KlevuFetchFunctionParams
Special parameters that are saved to query
undefined | KlevuFetchFunctionParams
• get id(): string
Id if the query
string
• get meta(): Object
Meta data of the query
Object
Name | Type | Description |
---|---|---|
apiKey | string | Klevu API key |
debuggingInformation | unknown | Information that can be useful for debugging the query. For example, the actual query that was fired by the Klevu Search engine, inclusive of any synonyms or de-compounded words taken into consideration. |
isPersonalised | boolean | - |
klevuImageData? | { processed: { urls: string[] }[] } | The urls processed in case of image search |
klevuImageData.processed | { urls: string[] }[] | - |
noOfResults | number | The number of results requested to be returned for this query. |
notificationCode | number | This may be populated with a code if any actions were taken on the record. Possible values are: 1: Nothing to report. 2: The price of the record is using the base currency. |
offset | number | The index of the first result returned in this response. |
qTime | number | The time taken by the Klevu Search engine to fetch the response. |
searchedTerm | string | The search term submitted for this query. |
totalResultsFound | number | The total number of results found for this query. |
typeOfSearch | The query type that was executed by Klevu to retrieve the results. |
• get records(): { id: string } & KlevuRecord[]
Records of the query
{ id: string } & KlevuRecord[]
▸ Private #initEventFunctions(): void
void
▸ Private #initRedirects(): void
void
▸ annotationsById(productId, languageCode): Promise<undefined | KlevuAnnotations>
Name | Type |
---|---|
productId | string |
languageCode | string |
Promise<undefined | KlevuAnnotations>
▸ getBanners(params?): Promise<KlevuBanner[]>
Name | Type | Description |
---|---|---|
params | Object | in case of search query you need to specify location of search |
params.searchType? | "landingpage" | "quicksearch" | - |
Promise<KlevuBanner[]>
List of banners that were received for this query
▸ getPage(params?): Promise<undefined | KlevuResponseObject>
Fetches page of results. If pageIndex is not defined it will fetch next page.
Name | Type | Description |
---|---|---|
params? | Object | |
params.filterManager? | Filter manager to apply for next function | |
params.limit? | number | Limit number of results for next query. By default this is automatically calculated from previous result |
params.pageIndex? | number | Use page index to load certain page instead of next available. 0 is first page |
Promise<undefined | KlevuResponseObject>
▸ getQueryParameters(): undefined | KlevuFetchFunctionParams
undefined | KlevuFetchFunctionParams
List of params used in the query and the metadata that was generated during the query. This is useful for example to fetching KMC metadata that was received for recommendations query.
▸ getTotalPages(): number
number
total number of pages
▸ hasNextPage(): boolean
boolean
true if there are more pages to fetch