Classes

Class: KlevuResponseQueryObject

60min

/ Exports / KlevuResponseQueryObject

Result object for each query. A storage for results. Can be used to fetch more data, send events etc.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new KlevuResponseQueryObject(responseObject, query, func)

Parameters

Name

Type

responseObject

query

func

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

Function used to create this query

Defined in



getRedirects

Optional getRedirects: () => Promise<KlevuKeywordUrlMap[]>

Type declaration

▸ (): Promise<KlevuKeywordUrlMap[]>

Fetches redirects for this query. This is available only for search queries

Returns

Promise<KlevuKeywordUrlMap[]>

Defined in



hooks

hooks: KlevuResultEventOnResult[] = []

Hooks that can be used to listen for events

Defined in



query

query: KlevuQueryResult

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: KlevuResponseObject

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 | (KlevuFilterResultOptions | KlevuFilterResultSlider | KlevuFilterResultRating)[]

All filters related to this query

Returns

Defined in



functionParams

get functionParams(): undefined | KlevuFetchFunctionParams

Special parameters that are saved to query

Returns

undefined | KlevuFetchFunctionParams

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

The query type that was executed by Klevu to retrieve the results.

Defined in



records

get records(): { id: string } & KlevuRecord[]

Records of the query

Returns

{ id: string } & KlevuRecord[]

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 | KlevuAnnotations>

Parameters

Name

Type

productId

string

languageCode

string

Returns

Promise<undefined | KlevuAnnotations>

Defined in



getBanners

getBanners(params?): Promise<KlevuBanner[]>

Parameters

Name

Type

Description

params

Object

in case of search query you need to specify location of search

params.searchType?

"landingpage" | "quicksearch"

-

Returns

Promise<KlevuBanner[]>

List of banners that were received for this query

Defined in



getPage

getPage(params?): Promise<undefined | KlevuResponseObject>

Fetches page of results. If pageIndex is not defined it will fetch next page.

Parameters

Name

Type

Description

params?

Object



params.filterManager?

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

Returns

Promise<undefined | KlevuResponseObject>

Defined in



getQueryParameters

getQueryParameters(): undefined | KlevuFetchFunctionParams

Returns

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.

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

Defined in

Updated 25 Mar 2024
Did this page help you?