JavaScript Search Framework Endpoints

A search endpoint is an object whose interface allows the JavaScript Search Framework to perform HTTP requests against the Search API (e.g., queries).

Thus, one of the first steps required to set up a functional search interface is to configure a search endpoint.

Configuring a New Search Endpoint

Use the configureCloudV2Endpoint method of the SearchEndpoint class to configure a new endpoint.

  • Initializing a simple endpoint relying on API key authentication.

    Coveo.SearchEndpoint.configureCloudV2Endpoint(
      "mycoveocloudv2organizationg8tp8wu3",
      "MY_API_KEY"
    );
    // ...
    Coveo.init(document.getElementById("search"));
    
  • Initializing a more complex endpoint targeting a HIPAA Coveo Cloud organization, and relying on search token authentication.

    const renewToken = () => {
      // Implementation ...
    };
    Coveo.SearchEndpoint.configureCloudV2Endpoint(
      "mycoveocloudv2organizationg8tp8wu3",
      "MY_SEARCH_TOKEN",
      "https://platformhipaa.cloud.coveo.com/rest/search",
      { renewAccessToken: renewToken }
    );
    // ...
    Coveo.init(document.getElementById("search"));
    

Configuring a Demo Search Endpoint

The SearchEndpoint class exposes a configureSampleEndpointV2 method allowing you to configure an endpoint that targets a demo organization whose index contains various sample items. This can be useful when you’re testing the framework.

Configuring a demo search endpoint.

Coveo.SearchEndpoint.configureSampleEndpointV2();
// ...
Coveo.init(document.getElementById("search"));
Recommended Articles