Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShopperSearch

Search for products and provide search suggestions.

Example with shopper auth

import { Search, ClientConfig, Customer, slasHelpers } from "commerce-sdk";
// or
const { Search, ClientConfig, Customer, slasHelpers } = require("commerce-sdk");

const clientConfig: ClientConfig = {
  parameters: {
    clientId: "XXXXXX",
    organizationId: "XXXX",
    shortCode: "XXX",
    siteId: "XX"
  }
};

// must be registered in SLAS. On server, redirectURI is never called
const redirectURI = "http://localhost:3000/callback";
const slasClient = new Customer.ShopperLogin(clientConfig);
token = await slasHelpers.loginGuestUser(slasClient, { redirectURI });

clientConfig.headers['authorization'] = `Bearer ${token.access_token}`;
const shopperSearchClient = new Search.ShopperSearch(clientConfig);
API Version: 1.0.23
Last Updated:

Hierarchy

  • BaseClient
    • ShopperSearch

Index

Type aliases

Static AsyncCreated

AsyncCreated: {}

Type declaration

Static BoolFilter

BoolFilter: { filters?: Array<any>; operator: string } & {}

Static BoolQuery

BoolQuery: { must?: Array<any>; mustNot?: Array<any>; should?: Array<any> } & {}

Static BrandSuggestions

BrandSuggestions: {} & {}

Static CategorySuggestions

CategorySuggestions: { categories?: Array<SuggestedCategory>; suggestedPhrases?: Array<SuggestedPhrase>; suggestedTerms: Array<SuggestedTerms> } & {}

Static ClosedObject

ClosedObject: {} & {}

Static CustomSuggestions

CustomSuggestions: { customSuggestion?: string; suggestedPhrases?: Array<SuggestedPhrase>; suggestedTerms: Array<SuggestedTerms> } & {}

Static DateConditionalRequest

DateConditionalRequest: {}

Type declaration

Static ErrorResponse

ErrorResponse: { detail?: string; instance?: string; title?: string; type: string } & {}

Static EtagConditionalRequest

EtagConditionalRequest: {}

Type declaration

Static EtagResponse

EtagResponse: {}

Type declaration

Static Filter

Filter: { boolFilter?: BoolFilter; queryFilter?: QueryFilter; range2Filter?: Range2Filter; rangeFilter?: RangeFilter; termFilter?: TermFilter } & {}

Static FilteredQuery

FilteredQuery: { filter: any; query: any } & {}

Static Image

Image: { alt?: string; disBaseLink?: string; link: string; title?: string } & {}

Static MatchAllQuery

MatchAllQuery: {} & {}

Static Money

Money: { currencyMnemonic?: string; value?: number } & {}

Static MoneyMnemonic

MoneyMnemonic: { currencyMnemonic?: string; value?: number } & {}

Static NestedQuery

NestedQuery: { path: string; query: any; scoreMode?: string } & {}

Static NoPropertiesAllowed

NoPropertiesAllowed: {}

Type declaration

Static OffsetPaginated

OffsetPaginated: {}

Type declaration

Static OpenObject

OpenObject: {} & {}

Static PaginatedSearchResult

PaginatedSearchResult: { hits?: Array<object>; limit: number; offset: any; query: any; sorts?: Array<Sort>; total: any } & {}

Static PaginatedSearchResultBase

PaginatedSearchResultBase: { hits?: Array<object>; limit: number; offset: any; query: any; sorts?: Array<Sort>; total: any } & {}

Static ProductRef

ProductRef: { id: string } & {}

Static ProductSearchHit

ProductSearchHit: { currency?: string; hitType?: string; image?: Image; orderable?: boolean; price?: number; priceMax?: number; prices?: {} & {}; productId: string; productName?: string; productType?: ProductType; representedProduct?: ProductRef; representedProducts?: Array<ProductRef>; variationAttributes?: Array<VariationAttribute> } & {}

Static ProductSearchRefinement

ProductSearchRefinement: { attributeId: string; label?: string; values?: Array<ProductSearchRefinementValue> } & {}

Static ProductSearchRefinementValue

ProductSearchRefinementValue: { description?: string; hitCount: number; label: string; presentationId?: string; value: string; values?: Array<ProductSearchRefinementValue> } & {}

Static ProductSearchResult

ProductSearchResult: { hits: Array<ProductSearchHit>; limit: number; offset: number; query: string; refinements: Array<ProductSearchRefinement>; searchPhraseSuggestions: Suggestion; selectedRefinements?: {} & {}; selectedSortingOption?: string; sortingOptions: Array<ProductSearchSortingOption>; total: number } & {}

Static ProductSearchSortingOption

ProductSearchSortingOption: { id: string; label: string } & {}

Static ProductSuggestions

ProductSuggestions: { products?: Array<SuggestedProduct>; suggestedPhrases?: Array<SuggestedPhrase>; suggestedTerms: Array<SuggestedTerms> } & {}

Static ProductType

ProductType: { bundle?: boolean; item?: boolean; master?: boolean; option?: boolean; set?: boolean; variant?: boolean; variationGroup?: boolean } & {}

Static Query

Query: { boolQuery?: BoolQuery; filteredQuery?: FilteredQuery; matchAllQuery?: MatchAllQuery; nestedQuery?: NestedQuery; termQuery?: TermQuery; textQuery?: TextQuery } & {}

Static QueryFilter

QueryFilter: { query: any } & {}

Static QueryParamsLimit

QueryParamsLimit: {}

Type declaration

Static QueryParamsOffset

QueryParamsOffset: {}

Type declaration

Static Range2Filter

Range2Filter: { filterMode?: string; fromField: string; fromInclusive?: boolean; fromValue?: any; toField: string; toInclusive?: boolean; toValue?: any } & {}

Static RangeFilter

RangeFilter: { field: string; from?: any; fromInclusive?: boolean; to?: any; toInclusive?: boolean } & {}

Static RateLimited

RateLimited: {}

Type declaration

Static RateLimited2

RateLimited2: {}

Type declaration

Static RateLimited3

RateLimited3: {}

Type declaration

Static RateLimited4

RateLimited4: {}

Type declaration

Static RateLimited5

RateLimited5: {}

Type declaration

Static SearchRequest

SearchRequest: { limit?: number; offset?: any; query: any; sorts?: Array<Sort> } & {}

Static SearchRequestBase

SearchRequestBase: { limit?: number; offset?: any; query: any; sorts?: Array<Sort> } & {}

Static SimpleSearchResult

SimpleSearchResult: { hits?: Array<object>; limit: number; offset: any; total: any } & {}

Static SimpleSearchResultBase

SimpleSearchResultBase: { hits?: Array<object>; limit: number; offset: any; total: any } & {}

Static SiteSpecific

SiteSpecific: {}

Type declaration

Static Sort

Sort: { field: string; sortOrder?: string } & {}

Static SpecifiedPropertiesAllowed

SpecifiedPropertiesAllowed: {} & {}

Static SuggestedCategory

SuggestedCategory: { id: string; name: string; parentCategoryName: string } & {}

Static SuggestedPhrase

SuggestedPhrase: { exactMatch: boolean; phrase: string } & {}

Static SuggestedProduct

SuggestedProduct: { currency: string; image?: Image; price: number; productId: string; productName: string } & {}

Static SuggestedTerm

SuggestedTerm: { completed: boolean; corrected: boolean; exactMatch: boolean; value: string } & {}

Static SuggestedTerms

SuggestedTerms: { originalTerm: string; terms?: Array<SuggestedTerm> } & {}

Static Suggestion

Suggestion: { suggestedPhrases?: Array<SuggestedPhrase>; suggestedTerms: Array<SuggestedTerms> } & {}

Static SuggestionResult

SuggestionResult: { brandSuggestions?: BrandSuggestions; categorySuggestions?: CategorySuggestions; customSuggestion?: CustomSuggestions; productSuggestions?: ProductSuggestions; searchPhrase: string } & {}

Static SyncCreated

SyncCreated: {}

Type declaration

Static TermFilter

TermFilter: { field: string; operator: string; values?: Array<any> } & {}

Static TermQuery

TermQuery: { fields: Array<string>; operator: string; values?: Array<any> } & {}

Static TextQuery

TextQuery: { fields: Array<string>; searchPhrase: string } & {}

Static VariationAttribute

VariationAttribute: { id: string; name?: string; values?: Array<VariationAttributeValue> } & {}

Static VariationAttributeValue

VariationAttributeValue: { description?: string; image?: Image; imageSwatch?: Image; name?: string; orderable?: boolean; value: string } & {}

Static badRequest

badRequest: {}

Type declaration

Constructors

constructor

  • Parameters

    • config: ClientConfig

    Returns ShopperSearch

Properties

clientConfig

clientConfig: ClientConfig

Methods

getSearchSuggestions

  • getSearchSuggestions(options?: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; organizationId?: string; q: string; siteId?: string } & {}; retrySettings?: OperationOptions }): Promise<SuggestionResult>
  • getSearchSuggestions<T>(options?: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; organizationId?: string; q: string; siteId?: string } & {}; retrySettings?: OperationOptions }, rawResponse?: T): Promise<T extends true ? Response : ShopperSearch.SuggestionResult>
  • Provides keyword search functionality for products, categories, and brands suggestions. Returns suggested products, suggested categories, and suggested brands for the given search phrase.

    If you would like to get a raw Response object use the other getSearchSuggestions function.

    Parameters

    • Optional options: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; organizationId?: string; q: string; siteId?: string } & {}; retrySettings?: OperationOptions }

      An object containing the options for this method.

      • Optional fetchOptions?: RequestInit
      • Optional headers?: {}
        • [key: string]: string
      • Optional parameters?: { currency?: string; limit?: number; locale?: string; organizationId?: string; q: string; siteId?: string } & {}
      • Optional retrySettings?: OperationOptions

    Returns Promise<SuggestionResult>

    A promise of type ShopperSearch.SuggestionResult.

  • Provides keyword search functionality for products, categories, and brands suggestions. Returns suggested products, suggested categories, and suggested brands for the given search phrase.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; organizationId?: string; q: string; siteId?: string } & {}; retrySettings?: OperationOptions }

      An object containing the options for this method.

      • Optional fetchOptions?: RequestInit
      • Optional headers?: {}
        • [key: string]: string
      • Optional parameters?: { currency?: string; limit?: number; locale?: string; organizationId?: string; q: string; siteId?: string } & {}
      • Optional retrySettings?: OperationOptions
    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true ? Response : ShopperSearch.SuggestionResult>

    A promise of type Response if rawResponse is true, a promise of type ShopperSearch.SuggestionResult otherwise.

productSearch

  • productSearch(options?: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; offset?: any; organizationId?: string; q?: string; refine?: Array<string>; siteId?: string; sort?: string } & {}; retrySettings?: OperationOptions }): Promise<ProductSearchResult>
  • productSearch<T>(options?: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; offset?: any; organizationId?: string; q?: string; refine?: Array<string>; siteId?: string; sort?: string } & {}; retrySettings?: OperationOptions }, rawResponse?: T): Promise<T extends true ? Response : ShopperSearch.ProductSearchResult>
  • Provides keyword and refinement search functionality for products. Only returns the product ID, link, and name in the product search hit. The search result contains only products that are online and assigned to site catalog.

    If you would like to get a raw Response object use the other productSearch function.

    Parameters

    • Optional options: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; offset?: any; organizationId?: string; q?: string; refine?: Array<string>; siteId?: string; sort?: string } & {}; retrySettings?: OperationOptions }

      An object containing the options for this method.

      • Optional fetchOptions?: RequestInit
      • Optional headers?: {}
        • [key: string]: string
      • Optional parameters?: { currency?: string; limit?: number; locale?: string; offset?: any; organizationId?: string; q?: string; refine?: Array<string>; siteId?: string; sort?: string } & {}
      • Optional retrySettings?: OperationOptions

    Returns Promise<ProductSearchResult>

    A promise of type ShopperSearch.ProductSearchResult.

  • Provides keyword and refinement search functionality for products. Only returns the product ID, link, and name in the product search hit. The search result contains only products that are online and assigned to site catalog.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: { fetchOptions?: RequestInit; headers?: {}; parameters?: { currency?: string; limit?: number; locale?: string; offset?: any; organizationId?: string; q?: string; refine?: Array<string>; siteId?: string; sort?: string } & {}; retrySettings?: OperationOptions }

      An object containing the options for this method.

      • Optional fetchOptions?: RequestInit
      • Optional headers?: {}
        • [key: string]: string
      • Optional parameters?: { currency?: string; limit?: number; locale?: string; offset?: any; organizationId?: string; q?: string; refine?: Array<string>; siteId?: string; sort?: string } & {}
      • Optional retrySettings?: OperationOptions
    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true ? Response : ShopperSearch.ProductSearchResult>

    A promise of type Response if rawResponse is true, a promise of type ShopperSearch.ProductSearchResult otherwise.

Generated using TypeDoc