Methods
// Returns a search response containing the results
xg.search.getResults({query: 'coat', options: {collection: '<collection>', deploymentId:'<deployment_id>'}});
// Returns a list of property values for the given collection
xg.search.getResultValues({collection: '<collection>'});
// Returns a search response for the given category and collection
xg.search.getCategoryPage({category: 'coat', collection: '<collection>'});
// Returns a list of trending search terms for the given collection
xg.search.getTrendingSearches({collection: '<collection>'});
getResults
getResults
Description: Gets recommendation results by a single elementId.
Parameters
Name | Type | Required | Description |
| string | ✅ | The ID of the element |
| object | ✅ | Options object that allows you to control the search result response |
↳
| string | ✅ | Collection to get items from |
↳
| string | ✅ | The deploymentId |
↳
| number | ❌ | The page of results |
↳
| boolean | ❌ | If facets should be returned or not |
↳
| boolean | ❌ | If deep search should be forced |
↳
| 'price' | 'update_date' | ❌ | Sort by price or update date |
↳
| 'asc' | 'desc' | ❌ | Sort order |
↳
| object | ❌ | Dynamic contextual information |
| string | ❌ | An optional queryId passed to cancel a request |
Returns
A Promise
resolving to the object below:
{
items: SearchProduct[];
facets: { [key: string]: unknown };
isFromCache: boolean;
page: number;
keyword: string;
isUrlRedirect: boolean;
isQueryTranslated: boolean;
isCachedFilterApplied: boolean;
isKeywordConfigApplied: boolean;
behaviorId: string;
responseEngine: string;
totalResults: number;
sortedBy: string;
variantMapping?: { [key: string]: string };
searchTermMatches?: string[];
}
getResultValues
getResultValues
Description: Gets the possible properties of a search result.
Parameters
Name | Type | Required | Description |
| string | ✅ | Collection to get items from |
Returns
A Promise
resolving to the object below:
{
[key: string]: {
name: string;
count: number;
}
}
getCategoryPage
getCategoryPage
Description: Gets results for a specific category page.
Parameters
Name | Type | Required | Description |
| string | ✅ | Category to get items from |
| string | ✅ | Collection to get items from |
| number | ❌ | Page number |
| string | ❌ | Optional queryId passed to cancel a request |
Returns
A Promise
resolving to the object below:
{
items: SearchProduct[];
facets: { [key: string]: unknown };
isFromCache: boolean;
page: number;
keyword: string;
isUrlRedirect: boolean;
isQueryTranslated: boolean;
isCachedFilterApplied: boolean;
isKeywordConfigApplied: boolean;
behaviorId: string;
responseEngine: string;
totalResults: number;
sortedBy: string;
variantMapping?: { [key: string]: string };
searchTermMatches?: string[];
}
getTrendingSearches
getTrendingSearches
Description: Gets the possible properties of a search result.
Parameters
Name | Type | Required | Description |
| string | ✅ | Collection to get items from |
Returns
A Promise
resolving to the array below:
string[];