Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SearchClient<T>

Package version

Class used to perform operations against a search index, including querying documents in the index as well as adding, updating, and removing them.

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

  • new SearchClient(apiVersion: string, endpoint: string, indexName: string, options?: coreHttp.ServiceClientOptions): SearchClient
  • Initializes a new instance of the SearchClient class.

    Example usage:

    const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
    
    const client = new SearchClient(
      "<endpoint>",
      "<indexName>",
      new AzureKeyCredential("<Admin Key>");
    );

    Example usage:

    const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
    
    const client = new SearchClient(
      "<endpoint>",
      "<indexName>",
      new AzureKeyCredential("<Admin Key>");
    );

    Parameters

    • apiVersion: string

      Client Api Version.

    • endpoint: string

      The endpoint URL of the search service.

    • indexName: string

      The name of the index.

    • Optional options: coreHttp.ServiceClientOptions

    Returns SearchClient

Properties

apiVersion

apiVersion: string = "2020-06-30"

The API version to use when communicating with the service.

documents

documents: Documents

endpoint

endpoint: string

The endpoint of the search service

indexName

indexName: string

The name of the index

Methods

autocomplete

  • Based on a partial searchText from the user, return a list of potential completion strings based on a specified suggester.

    Type parameters

    • Fields: keyof T

    Parameters

    • searchText: string

      The search text on which to base autocomplete results.

    • suggesterName: string

      The name of the suggester as specified in the suggesters collection that's part of the index definition.

    • Default value options: AutocompleteOptions<Fields> = {}

      Options to the autocomplete operation.

    Returns Promise<AutocompleteResult>

deleteDocuments

getDocument

  • Retrieve a particular document from the index by key.

    Type parameters

    • Fields: keyof T

    Parameters

    • key: string

      The primary key value of the document

    • Default value options: GetDocumentOptions<Fields> = {}

      Additional options

    Returns Promise<T>

getDocumentsCount

getSearchIndexingBufferedSenderInstance

indexDocuments

mergeDocuments

mergeOrUploadDocuments

search

  • search<Fields>(searchText?: undefined | string, options?: SearchOptions<Fields>): Promise<SearchDocumentsResult<Pick<T, Fields>>>
  • Performs a search on the current index given the specified arguments.

    Type parameters

    • Fields: keyof T

    Parameters

    • Optional searchText: undefined | string

      Text to search

    • Default value options: SearchOptions<Fields> = {}

      Options for the search operation.

    Returns Promise<SearchDocumentsResult<Pick<T, Fields>>>

suggest

  • suggest<Fields>(searchText: string, suggesterName: string, options?: SuggestOptions<Fields>): Promise<SuggestDocumentsResult<Pick<T, Fields>>>
  • Returns a short list of suggestions based on the searchText and specified suggester.

    Type parameters

    • Fields: keyof T

    Parameters

    • searchText: string

      The search text to use to suggest documents. Must be at least 1 character, and no more than 100 characters.

    • suggesterName: string

      The name of the suggester as specified in the suggesters collection that's part of the index definition.

    • Default value options: SuggestOptions<Fields> = {}

      Options for the suggest operation

    Returns Promise<SuggestDocumentsResult<Pick<T, Fields>>>

uploadDocuments

Generated using TypeDoc