Options
All
  • Public
  • Public/Protected
  • All
Menu

The Categorize service queries the search-engine for which categories that any search-matches for the same query will contain.

It is normally used indirectly via the SearchClient class.

Hierarchy

Index

Constructors

constructor

  • Creates a Categorize instance that handles fetching categories dependent on settings and query. Supports registering a callback in order to receive categories when they have been received.

    Parameters

    • Optional settings: string | ICategorizeSettings

      The settings that define how the Categorize instance is to operate.

    • Optional auth: AuthToken

      An object that handles the authentication.

    • Optional fetchMethod: (input: RequestInfo, init?: RequestInit) => Promise<Response>
        • (input: RequestInfo, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo
          • Optional init: RequestInit

          Returns Promise<Response>

    Returns Categorize

Properties

categories

categories: ICategories

This represents the last categories that was received from the backend.

Note: Normally these are only used internally. You can however populate these yourself, but if you are also executing fetches (which the SearchClient is often doing in the automatic mode) then the contents may be overwritten at any time.

settings

Accessors

deferUpdateState

  • get deferUpdateState(): boolean
  • Can be used to check the state of deferUpdates.

    Returns boolean

numAborted

  • get numAborted(): number
  • The number of times this service-instance has aborted a request (typically as a result to starting a new request while the previous is still running and needs to be aborted).

    Returns number

numCancelled

  • get numCancelled(): number
  • The number of times this service-instance has cancelled a request (as directed from a user cbRequest rejection).

    Returns number

numCompleted

  • get numCompleted(): number
  • The number of times this service-instance has completed a request (not counting aborted or cancelled requests).

    Returns number

numFailed

  • get numFailed(): number
  • The number of times this service-instance has failed during a request (not counting aborted or cancelled requests).

    Returns number

numRequested

  • get numRequested(): number
  • The number of times this service-instance has started a request.

    Returns number

Methods

categorizationTypeChanged

clientCategoriesUpdate

  • clientCategoriesUpdate(query: IQuery): void
  • Parameters

    Returns void

clientIdChanged

  • clientIdChanged(oldValue: string, query: IQuery): void

createCategoryFilter

  • Creates a Filter object based on the input id (string [] or Category).

    NB! This method does NOT apply the filter in the filters collection. It is used behind the scenes by the filter* methods in SearchClient. To apply a filter you need to use the filter* properties/methods in SearchClient.

    If the category doesn't exist then the filter will not be created.

    If passing in a string[] then the value is expected to match the categoryName property of a listed category.

    Parameters

    • categoryName: string[] | ICategory

      A string array or a Category that denotes the category to create a filter for.

    Returns Filter

dateFromChanged

dateToChanged

deferUpdates

  • deferUpdates(state: boolean, skipPending?: boolean): void
  • Decides whether an update should be executed or not. Typically used to temporarily turn off update-execution. When turned back on the second param can be used to indicate whether pending updates should be executed or not.

    Parameters

    • state: boolean

      Turns on or off deferring of updates.

    • skipPending: boolean = false

      Used to indicate if a pending update is to be executed or skipped when deferring is turned off. The param is ignored for state=true.

    Returns void

fetch

  • Fetches the results from the server.

    Parameters

    • Optional query: IQuery

      The query-object that controls which results that are to be returned.

    • Optional suppressCallbacks: boolean

      Set to true if you have defined callbacks, but somehow don't want them to be called.

    Returns Promise<ICategories>

    a promise that when resolved returns the data.

filtersChanged

findCategory

  • Find the category based on the category-name array.

    Parameters

    • categoryName: string[]

      The category array that identifies the category.

    • Optional categories: ICategories

    Returns ICategory | IGroup

    The Category object if found or null.

matchGenerateContentChanged

  • matchGenerateContentChanged(oldValue: boolean, query: IQuery): void

matchGenerateContentHighlightsChanged

  • matchGenerateContentHighlightsChanged(oldValue: boolean, query: IQuery): void

matchGroupingChanged

  • matchGroupingChanged(oldValue: boolean, query: IQuery): void

matchOrderByChanged

matchPageChanged

  • matchPageChanged(oldValue: number, query: IQuery): void

matchPageSizeChanged

  • matchPageSizeChanged(oldValue: number, query: IQuery): void

maxSuggestionsChanged

  • maxSuggestionsChanged(oldValue: number, query: IQuery): void

queryTextChanged

  • queryTextChanged(oldValue: string, query: IQuery): void

requestObject

  • requestObject(includeAuthorizationHeader?: boolean): RequestInit
  • Sets up the Request that is to be executed, with headers and auth as needed.

    Parameters

    • includeAuthorizationHeader: boolean = true

      Set to false to not include the auth jwt token in the request headers. Default=true

    Returns RequestInit

searchTypeChanged

shouldUpdate

  • shouldUpdate(fieldName?: string, query?: IQuery): boolean
  • Parameters

    • Optional fieldName: string
    • Optional query: IQuery

    Returns boolean

uiLanguageCodeChanged

  • uiLanguageCodeChanged(oldValue: string, query: IQuery): void

update

  • update(query: IQuery, delay?: number, useQueryMatchPage?: boolean): void
  • Call the service, but take into account deferredUpdates.

    Parameters

    • query: IQuery

      The query object to create the fetch for.

    • Optional delay: number

      A delay for when to execute the update, in milliseconds. Defaults to undefined.

    • Optional useQueryMatchPage: boolean

      If true then the query match-page number will not be reset to 1. Otherwise it is by default always 1.

    Returns void

Generated using TypeDoc