UNPKG

@azure/search-documents

Version:
57 lines 2.81 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { createSearch } from "./api/index.js"; import { autocompletePost, autocompleteGet, index, suggestPost, suggestGet, getDocument, searchPost, searchGet, getDocumentCount, } from "./api/operations.js"; export class SearchClient { _client; /** The pipeline used by this client to make requests */ pipeline; constructor(endpointParam, credential, indexName, options = {}) { const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-client` : `azsdk-js-client`; this._client = createSearch(endpointParam, credential, indexName, { ...options, userAgentOptions: { userAgentPrefix }, }); this.pipeline = this._client.pipeline; } /** Autocompletes incomplete query terms based on input text and matching terms in the index. */ autocompletePost(searchText, suggesterName, options = { requestOptions: {} }) { return autocompletePost(this._client, searchText, suggesterName, options); } /** Autocompletes incomplete query terms based on input text and matching terms in the index. */ autocompleteGet(searchText, suggesterName, options = { requestOptions: {} }) { return autocompleteGet(this._client, searchText, suggesterName, options); } /** Sends a batch of document write actions to the index. */ index(batch, options = { requestOptions: {} }) { return index(this._client, batch, options); } /** Suggests documents in the index that match the given partial query text. */ suggestPost(searchText, suggesterName, options = { requestOptions: {} }) { return suggestPost(this._client, searchText, suggesterName, options); } /** Suggests documents in the index that match the given partial query text. */ suggestGet(searchText, suggesterName, options = { requestOptions: {} }) { return suggestGet(this._client, searchText, suggesterName, options); } /** Retrieves a document from the index. */ getDocument(key, options = { requestOptions: {} }) { return getDocument(this._client, key, options); } /** Searches for documents in the index. */ searchPost(options = { requestOptions: {} }) { return searchPost(this._client, options); } /** Searches for documents in the index. */ searchGet(options = { requestOptions: {} }) { return searchGet(this._client, options); } /** Queries the number of documents in the index. */ getDocumentCount(options = { requestOptions: {} }) { return getDocumentCount(this._client, options); } } //# sourceMappingURL=searchClient.js.map