Class SearchEndpoint

The SearchEndpoint class allows the framework to perform HTTP requests against the Search API (e.g., searching, getting query suggestions, getting the HTML preview of an item, etc.).

Note:

When writing custom code that interacts with the Search API, be aware that executing queries directly through an instance of this class will not trigger any query events.

In some cases, this may be what you want. However, if you do want query events to be triggered (e.g., to ensure that standard components update themselves as expected), use the queryController instance instead.

Additional documentation

JavaScript Search Framework Endpoint

Index

Methods

deleteSubscription

exchangeHandshakeToken

  • Exchanges a temporary handshake token to either get an initial access token or extend the privileges of an existing access token.

    Parameters

    Returns Promise<string>

    The access token.

extensions

  • Lists all available query extensions for the search endpoint.

    Parameters

    Returns Promise<IExtension[]>

    A Promise of the extensions.

facetSearch

fetchBinary

  • Performs a search on the index and returns a Promise of ArrayBuffer.

    Parameters

    Returns Promise<ArrayBuffer>

    A Promise of query results.

follow

getAuthenticationProviderUri

  • Gets the URI that can be used to authenticate against the given provider.

    Parameters

    • provider: string

      The provider name.

    • Optional returnUri: string

      The URI to return to after the authentication is completed.

    • Optional message: string

      The authentication message.

    • Optional callOptions: IEndpointCallOptions

      Additional set of options to use for this call.

    • Optional callParams: IEndpointCallParameters

      Options injected by the applied decorators.

    Returns string

    The authentication provider URI.

getBaseAlertsUri

  • getBaseAlertsUri(): string
  • Gets the base URI of the search alerts endpoint.

    Returns string

    The base URI of the search alerts endpoint.

getBaseUri

  • getBaseUri(): string
  • Gets the base URI of the Search API endpoint.

    Returns string

    The base URI of the Search API endpoint.

getDocument

getDocumentHtml

  • Gets the content for a single item, as an HTMLDocument (think: quickview).

    Parameters

    Returns Promise<HTMLDocument>

    A Promise of the item content.

getDocumentText

getExportToExcelLink

  • deprecated

    getExportToExcelLink does not factor in all query parameters (e.g. dynamic facets) due to GET request url length limitations. Please use fetchBinary instead to ensure all query parameters are used.

    Gets a link / URI to download a query result set to the XLSX format.

    Note:

    This method does not automatically download the query result set, but rather provides an URI from which to download it.

    Parameters

    • query: IQuery

      The query for which to get the XLSX result set.

    • numberOfResults: number

      The number of results to download.

    • Optional callOptions: IEndpointCallOptions

      An additional set of options to use for this call.

    • Optional callParams: IEndpointCallParameters

      The options injected by the applied decorators.

    Returns string

    The download URI.

getQuerySuggest

getRawDataStream

  • Gets the raw datastream for an item. This is typically used to get a thumbnail for an item.

    Returns an array buffer.

    Example:

    let rawBinary = String.fromCharCode.apply(null, new Uint8Array(response));
    img.setAttribute('src', 'data:image/png;base64,' + btoa(rawBinary));
    

    Parameters

    Returns Promise<ArrayBuffer>

getViewAsDatastreamUri

  • Gets an URL from which it is possible to see the datastream for an item. This is typically used to get a thumbnail for an item.

    Parameters

    • documentUniqueID: string

      Typically, the IQueryResult.uniqueId on each result.

    • dataStreamType: string

      Normally, $Thumbnail.

    • Default value callOptions: IViewAsHtmlOptions = {}

      An additional set of options to use for this call.

    • Optional callParams: IEndpointCallParameters

      The options injected by the applied decorators.

    Returns string

    The datastream URL.

getViewAsHtmlUri

isJsonp

  • isJsonp(): boolean
  • Indicates whether the search endpoint is using JSONP internally to communicate with the Search API.

    Returns boolean

    true in the search enpoint is using JSONP; false otherwise.

listFieldValues

listFieldValuesBatch

listFields

  • Lists all fields for the index, and returns an array of their descriptions.

    Parameters

    Returns Promise<IFieldDescription[]>

    A Promise of the index fields and descriptions.

listSubscriptions

  • Gets a Promise of an array of the current subscriptions.

    Parameters

    • Optional page: number

      The page of the subscriptions.

    • Optional callOptions: IEndpointCallOptions

      An additional set of options to use for this call.

    • Optional callParams: IEndpointCallParameters

      The options injected by the applied decorators.

    Returns Promise<ISubscription[]>

plan

rateDocument

  • Note:

    The Coveo Cloud V2 platform does not support collaborative rating. Therefore, this method is obsolete in Coveo Cloud V2.

    Rates a single item in the index (granted that collaborative rating is enabled on your index)

    Parameters

    Returns Promise<boolean>

search

  • Performs a search on the index and returns a Promise of IQueryResults.

    This method slightly modifies the query results by adding additional information to each result (id, state object, etc.).

    Parameters

    Returns Promise<IQueryResults>

    A Promise of query results.

setRequestModifier

  • setRequestModifier(requestModifier: function): void
  • Sets a function which allows external code to modify all endpoint call parameters before the browser sends them.

    Note:

    This is useful in very specific scenarios where the network infrastructure requires special request headers to be added or removed, for example.

    Parameters

    Returns void

tagDocument

updateSubscription

Static configureCloudEndpoint

  • configureCloudEndpoint(organization?: string, token?: string, uri?: string, otherOptions?: ISearchEndpointOptions): void
  • Configures a search endpoint on a Coveo Cloud V1 index.

    Parameters

    • Optional organization: string

      The organization ID of your Coveo Cloud index.

    • Optional token: string

      The token to use to execute query. If not specified, you will likely need to login when querying.

    • Default value uri: string = "https://cloudplatform.coveo.com/rest/search"

      The URI of the Coveo Cloud REST Search API. By default, this points to the production environment.

    • Optional otherOptions: ISearchEndpointOptions

      A set of additional options to use when configuring this endpoint.

    Returns void

Static configureCloudV2Endpoint

  • configureCloudV2Endpoint(organization?: string, token?: string, uri?: string, otherOptions?: ISearchEndpointOptions): void
  • Configures a new search endpoint on a Coveo Cloud V2 organization.

    Parameters

    • Optional organization: string

      The unique identifier of the target Coveo Cloud V2 organization (e.g., mycoveocloudv2organizationg8tp8wu3).

    • Optional token: string

      The access token to authenticate Search API requests with (i.e., an API key or a search token).

      Note: This token will also authenticate Usage Analytics Write API requests if the search interface initializes an Analytics component whose token option is unspecified.

    • Default value uri: string = "https://platform.cloud.coveo.com/rest/search"

      The base URI of the Search API.

      Allowed values:

      • https://platform.cloud.coveo.com/rest/search (for organizations in the standard Coveo Cloud V2 environment)
      • https://platform-eu.cloud.coveo.com/rest/search (for organizations with European data residency)
      • https://platform-au.cloud.coveo.com/rest/search (for organizations with Australian data residency)
      • https://platformhipaa.cloud.coveo.com/rest/search (for HIPAA organizations)

      Default: https://platform.cloud.coveo.com/rest/search

    • Optional otherOptions: ISearchEndpointOptions

      Additional options to apply for this endpoint (e.g., a renewAccessToken function).

    Returns void

Static configureOnPremiseEndpoint

  • Configures a search endpoint on a Coveo on-premise index.

    Parameters

    • uri: string

      The URI of your Coveo Search API endpoint (e.g., http://myserver:8080/rest/search)

    • Optional token: string

      The token to use to execute query. If not specified, you will likely need to login when querying (unless your Coveo Search API endpoint is configured using advanced auth options, such as Windows auth or claims).

    • Optional otherOptions: ISearchEndpointOptions

      A set of additional options to use when configuring this endpoint.

    Returns void

Static configureSampleEndpoint

  • Configures a demo search endpoint on a Coveo Cloud V1 organization whose index contains various types of non-secured items.

    Note: This method mainly exists for demo and testing purposes.

    Parameters

    Returns void

Static configureSampleEndpointV2

  • Configures a demo search endpoint on a Coveo Cloud V2 organization whose index contains various types of non-secured items.

    Note: This method mainly exists for demo and testing purposes.

    Parameters

    Returns void

Properties

Static endpoints

endpoints: object

A map of all initialized SearchEndpoint instances.

Example: Coveo.SearchEndpoint.endpoints["default"] returns the default endpoint that was created at initialization.

type

{{}}

Type declaration

Constructors

constructor

  • Creates a new SearchEndpoint instance. Uses a set of adequate default options, and merges these with the options parameter. Also creates an EndpointCaller instance and uses it to communicate with the endpoint internally.

    Parameters

    Returns SearchEndpoint

Hierarchy

  • SearchEndpoint

Implements

  • ISearchEndpoint