Result Object
KlevuFetch() result object contains raw API response and handy helpers to work with the results. For example use suggestionsById() to fetch suggestions results and queriesById() for search results.
queriesById() result contains metadata for query, getPage(), the result records and possible event functions for providing click events to search, category merchandising and recommendations.
Calling these event functions returns a function to use to send events to Klevu.
getPage() is a nice helper to fetch the next results set or certain page of results set with the same queries and modifiers.
You can use hasNextPage() method to check if there are more pages available. Passing pageIndex parameter to getPage() allows you to fetch records for certain page.
getBanners() method of searchResultQuery object can be used to fetch all banners related to that search. In case of a search we need to provide do we want banners for quicksearch or search landing page. In case of merchandising banners we do not need to provide anything for the method.
getRedirects method of searchResultQuery will be defined in case that typical search was made. It will return all directs that are matched (usually one) to the search. This allows you to create your own redirection logic.
Here is very simple logic that you can use to do the redirects in the browser.
When you perform a search using KlevuFetch, each query can be accessed using getQueriesById as shown above.
There are three possible click events returned by getQueriesById(): searchClickEvent(), categoryMerchandisingClickEvent() and recommendationClickEvent()
These three functions are defined and available only if query has been correct type. So for example search() query has only searchClickEvent() defined.
Function Name | Returned by |
---|---|
searchClickEvent() | search() |
categoryMerchandisingClickEvent() | categoryMerchandising() |
recommendationClickEvent() | kmcRecommendation() |
For exact information regarding what is returned by searches and what to pass to these search events please refer to the Reference section.