Class: KlevuResponseQueryObject
Result object for each query. A storage for results. Can be used to fetch more data, send events etc.
Table of contents
Constructors
- constructorconstructor
Properties
- categoryMerchandisingClickEventcategoryMerchandisingClickEvent
- funcfunc
- getRedirectsgetRedirects
- hookshooks
- queryquery
- recommendationBannerClickEventrecommendationBannerClickEvent
- recommendationClickEventrecommendationClickEvent
- responseObjectresponseObject
- searchClickEventsearchClickEvent
Accessors
- filtersfilters
- functionParamsfunctionParams
- idid
- metameta
- recordsrecords
Methods
- #initEventFunctions#initEventFunctions
- #initRedirects#initRedirects
- annotationsByIdannotationsById
- getBannersgetBanners
- getPagegetPage
- getQueryParametersgetQueryParameters
- getTotalPagesgetTotalPages
- hasNextPagehasNextPage
Constructors
constructor
• new KlevuResponseQueryObject(responseObject, query, func)
Parameters
Name | Type |
|---|---|
responseObject | KlevuResponseObjectKlevuResponseObject |
query | KlevuQueryResultKlevuQueryResult |
func | KlevuFetchFunctionReturnValueKlevuFetchFunctionReturnValue |
Defined in
Properties
categoryMerchandisingClickEvent
• Optional categoryMerchandisingClickEvent: (params: { categoryTitle: string ; override?: Partial<KlevuV1CategoryProductsView> ; productId: string ; variantId?: string }) => void
Type declaration
▸ (params): void
When query is categoryMerchandising this is available. It is used to send categoryMerchandising click events
Parameters
Name | Type |
|---|---|
params | Object |
params.categoryTitle | string |
params.override? | Partial<KlevuV1CategoryProductsView> |
params.productId | string |
params.variantId? | string |
Returns
void
Defined in
func
• func: KlevuFetchFunctionReturnValueKlevuFetchFunctionReturnValue
Function used to create this query
Defined in
getRedirects
• Optional getRedirects: () => Promise<KlevuKeywordUrlMapKlevuKeywordUrlMap[]>
Type declaration
▸ (): Promise<KlevuKeywordUrlMapKlevuKeywordUrlMap[]>
Fetches redirects for this query. This is available only for search queries
Returns
Promise<KlevuKeywordUrlMapKlevuKeywordUrlMap[]>
Defined in
hooks
• hooks: KlevuResultEventOnResultKlevuResultEventOnResult[] = []
Hooks that can be used to listen for events
Defined in
query
• query: KlevuQueryResultKlevuQueryResult
This query
Defined in
recommendationBannerClickEvent
• Optional recommendationBannerClickEvent: (params: { resolution: "desktop" | "mobile" }) => void
Type declaration
▸ (params): void
When there is a banner in the recommendation this is available. It is used to send recommendation banner click events
Parameters
Name | Type |
|---|---|
params | Object |
params.resolution | "desktop" | "mobile" |
Returns
void
Defined in
recommendationClickEvent
• Optional recommendationClickEvent: (params: { override?: Partial<KlevuRecommendationsEventV2Data> ; productId: string ; variantId?: string }) => void
Type declaration
▸ (params): void
When query is recommendation this is available. It is used to send recommendation click events
Parameters
Name | Type |
|---|---|
params | Object |
params.override? | Partial<KlevuRecommendationsEventV2Data> |
params.productId | string |
params.variantId? | string |
Returns
void
Defined in
responseObject
• responseObject: KlevuResponseObjectKlevuResponseObject
Original request response that includes all queries
Defined in
searchClickEvent
• Optional searchClickEvent: (params: { autoSendViewEvent?: boolean ; override?: Partial<V1SearchEvent> ; productId: string ; variantId?: string }) => void
Type declaration
▸ (params): void
When query is search this is available. It is used to send search click events
Parameters
Name | Type |
|---|---|
params | Object |
params.autoSendViewEvent? | boolean |
params.override? | Partial<V1SearchEvent> |
params.productId | string |
params.variantId? | string |
Returns
void
Defined in
Accessors
filters
• get filters(): undefined | (KlevuFilterResultOptionsKlevuFilterResultOptions | KlevuFilterResultSliderKlevuFilterResultSlider | KlevuFilterResultRatingKlevuFilterResultRating)[]
All filters related to this query
Returns
undefined | (KlevuFilterResultOptionsKlevuFilterResultOptions | KlevuFilterResultSliderKlevuFilterResultSlider | KlevuFilterResultRatingKlevuFilterResultRating)[]
Defined in
functionParams
• get functionParams(): undefined | KlevuFetchFunctionParamsKlevuFetchFunctionParams
Special parameters that are saved to query
Returns
undefined | KlevuFetchFunctionParamsKlevuFetchFunctionParams
Defined in
id
• get id(): string
Id if the query
Returns
string
Defined in
meta
• get meta(): Object
Meta data of the query
Returns
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 | KlevuTypeOfSearchKlevuTypeOfSearch | The query type that was executed by Klevu to retrieve the results. |
Defined in
records
• get records(): { id: string } & KlevuRecordKlevuRecord[]
Records of the query
Returns
{ id: string } & KlevuRecordKlevuRecord[]
Defined in
Methods
#initEventFunctions
▸ Private #initEventFunctions(): void
Returns
void
Defined in
#initRedirects
▸ Private #initRedirects(): void
Returns
void
Defined in
annotationsById
▸ annotationsById(productId, languageCode): Promise<undefined | KlevuAnnotationsKlevuAnnotations>
Parameters
Name | Type |
|---|---|
productId | string |
languageCode | string |
Returns
Promise<undefined | KlevuAnnotationsKlevuAnnotations>
Defined in
getBanners
▸ getBanners(params?): Promise<KlevuBannerKlevuBanner[]>
Parameters
Name | Type | Description |
|---|---|---|
params | Object | in case of search query you need to specify location of search |
params.searchType? | "landingpage" | "quicksearch" | - |
Returns
Promise<KlevuBannerKlevuBanner[]>
List of banners that were received for this query
Defined in
getPage
▸ getPage(params?): Promise<undefined | KlevuResponseObjectKlevuResponseObject>
Fetches page of results. If pageIndex is not defined it will fetch next page.
Parameters
Name | Type | Description |
|---|---|---|
params? | Object | |
params.filterManager? | FilterManagerFilterManager | 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 |
Returns
Promise<undefined | KlevuResponseObjectKlevuResponseObject>
Defined in
getQueryParameters
▸ getQueryParameters(): undefined | KlevuFetchFunctionParamsKlevuFetchFunctionParams
Returns
undefined | KlevuFetchFunctionParamsKlevuFetchFunctionParams
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.
Defined in
getTotalPages
▸ getTotalPages(): number
Returns
number
total number of pages
Defined in
hasNextPage
▸ hasNextPage(): boolean
Returns
boolean
true if there are more pages to fetch