How to use @elastic/app-search-javascript - 1 common examples

To help you get started, we’ve selected a few @elastic/app-search-javascript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / search-ui / packages / search-ui-app-search-connector / src / AppSearchAPIConnector.js View on Github external
searchKey,
    engineName,
    hostIdentifier,
    beforeSearchCall = (queryOptions, next) => next(queryOptions),
    beforeAutocompleteResultsCall = (queryOptions, next) => next(queryOptions),
    beforeAutocompleteSuggestionsCall = (queryOptions, next) =>
      next(queryOptions),
    endpointBase = ""
  }) {
    if (!engineName || !(hostIdentifier || endpointBase) || !searchKey) {
      throw Error(
        "hostIdentifier or endpointBase, engineName, and searchKey are required"
      );
    }

    this.client = ElasticAppSearch.createClient({
      ...(endpointBase && { endpointBase }), //Add property on condition
      ...(hostIdentifier && { hostIdentifier: hostIdentifier }),
      apiKey: searchKey,
      engineName: engineName,
      additionalHeaders: {
        "x-swiftype-integration": "search-ui",
        "x-swiftype-integration-version": version
      }
    });
    this.beforeSearchCall = beforeSearchCall;
    this.beforeAutocompleteResultsCall = beforeAutocompleteResultsCall;
    this.beforeAutocompleteSuggestionsCall = beforeAutocompleteSuggestionsCall;
  }

@elastic/app-search-javascript

Javascript client for the Elastic App Search Api

Apache-2.0
Latest version published 2 months ago

Package Health Score

71 / 100
Full package analysis

Popular @elastic/app-search-javascript functions

Similar packages