XSearch Service

Prev Next

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

query

string

The ID of the element

options

object

Options object that allows you to control the search result response

options.collection

string

Collection to get items from

options.deploymentId

string

The deploymentId

options.page

number

The page of results

options.facets

boolean

If facets should be returned or not

options.forceDeepSearch

boolean

If deep search should be forced

options.sortBy

'price' | 'update_date'

Sort by price or update date

options.sortOrder

'asc' | 'desc'

Sort order

options.context

object

Dynamic contextual information

queryId

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

collection

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

category

string

Category to get items from

collection

string

Collection to get items from

page

number

Page number

queryId

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

collection

string

Collection to get items from

Returns

A Promise resolving to the array below:

string[];