SearchIndexClient class

Class to perform operations to manage (create, update, list/delete) indexes, & synonymmaps.

Constructors

SearchIndexClient(string, KeyCredential | TokenCredential, SearchIndexClientOptions)

Creates an instance of SearchIndexClient.

Example usage:

const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents");

const client = new SearchIndexClient(
  "<endpoint>",
  new AzureKeyCredential("<Admin Key>");
);

Properties

apiVersion

The API version to use when communicating with the service.

endpoint

The endpoint of the search service

serviceVersion

The API version to use when communicating with the service.

Methods

analyzeText(string, AnalyzeTextOptions)

Calls an analyzer or tokenizer manually on provided text.

createIndex(SearchIndex, OperationOptions)

Creates a new index.

createOrUpdateIndex(SearchIndex, CreateOrUpdateIndexOptions)

Creates a new index or modifies an existing one.

createOrUpdateSynonymMap(SynonymMap, CreateOrUpdateSynonymMapOptions)

Creates a new SynonymMap or modifies an existing one.

createSynonymMap(SynonymMap, OperationOptions)

Creates a new SynonymMap in a search service.

deleteIndex(string | SearchIndex, DeleteIndexOptions)

Deletes an existing index.

deleteSynonymMap(string | SynonymMap, DeleteSynonymMapOptions)

Deletes an existing SynonymMap.

getIndex(string, OperationOptions)

Retrieves information about an index.

getIndexStatistics(string, OperationOptions)

Retrieves statistics about an index, such as the count of documents and the size of index storage.

getSearchClient<TModel>(string, SearchClientOptions)

Retrieves the SearchClient corresponding to this SearchIndexClient

getServiceStatistics(OperationOptions)

Retrieves statistics about the service, such as the count of documents, index, etc.

getSynonymMap(string, OperationOptions)

Retrieves information about a SynonymMap.

listIndexes(OperationOptions)

Retrieves a list of existing indexes in the service.

listIndexesNames(OperationOptions)

Retrieves a list of names of existing indexes in the service.

listSynonymMaps(OperationOptions)

Retrieves a list of existing SynonymMaps in the service.

listSynonymMapsNames(OperationOptions)

Retrieves a list of names of existing SynonymMaps in the service.

Constructor Details

SearchIndexClient(string, KeyCredential | TokenCredential, SearchIndexClientOptions)

Creates an instance of SearchIndexClient.

Example usage:

const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents");

const client = new SearchIndexClient(
  "<endpoint>",
  new AzureKeyCredential("<Admin Key>");
);
new SearchIndexClient(endpoint: string, credential: KeyCredential | TokenCredential, options?: SearchIndexClientOptions)

Parameters

endpoint

string

The endpoint of the search service

credential

KeyCredential | TokenCredential

Used to authenticate requests to the service.

options
SearchIndexClientOptions

Used to configure the Search Index client.

Property Details

apiVersion

Warning

This API is now deprecated.

use {@Link serviceVersion} instead

The API version to use when communicating with the service.

apiVersion: string

Property Value

string

endpoint

The endpoint of the search service

endpoint: string

Property Value

string

serviceVersion

The API version to use when communicating with the service.

serviceVersion: string

Property Value

string

Method Details

analyzeText(string, AnalyzeTextOptions)

Calls an analyzer or tokenizer manually on provided text.

function analyzeText(indexName: string, options: AnalyzeTextOptions): Promise<AnalyzeResult>

Parameters

indexName

string

The name of the index that contains the field to analyze

options
AnalyzeTextOptions

Additional arguments

Returns

Promise<AnalyzeResult>

createIndex(SearchIndex, OperationOptions)

Creates a new index.

function createIndex(index: SearchIndex, options?: OperationOptions): Promise<SearchIndex>

Parameters

index
SearchIndex

The information describing the index to be created.

options
OperationOptions

Additional optional arguments.

Returns

Promise<SearchIndex>

createOrUpdateIndex(SearchIndex, CreateOrUpdateIndexOptions)

Creates a new index or modifies an existing one.

function createOrUpdateIndex(index: SearchIndex, options?: CreateOrUpdateIndexOptions): Promise<SearchIndex>

Parameters

index
SearchIndex

The information describing the index to be created.

options
CreateOrUpdateIndexOptions

Additional optional arguments.

Returns

Promise<SearchIndex>

createOrUpdateSynonymMap(SynonymMap, CreateOrUpdateSynonymMapOptions)

Creates a new SynonymMap or modifies an existing one.

function createOrUpdateSynonymMap(synonymMap: SynonymMap, options?: CreateOrUpdateSynonymMapOptions): Promise<SynonymMap>

Parameters

synonymMap
SynonymMap

The information describing the SynonymMap to be created.

options
CreateOrUpdateSynonymMapOptions

Additional optional arguments.

Returns

Promise<SynonymMap>

createSynonymMap(SynonymMap, OperationOptions)

Creates a new SynonymMap in a search service.

function createSynonymMap(synonymMap: SynonymMap, options?: OperationOptions): Promise<SynonymMap>

Parameters

synonymMap
SynonymMap

The synonymMap definition to create in a search service.

options
OperationOptions

Additional optional arguments.

Returns

Promise<SynonymMap>

deleteIndex(string | SearchIndex, DeleteIndexOptions)

Deletes an existing index.

function deleteIndex(index: string | SearchIndex, options?: DeleteIndexOptions): Promise<void>

Parameters

index

string | SearchIndex

options
DeleteIndexOptions

Additional optional arguments.

Returns

Promise<void>

deleteSynonymMap(string | SynonymMap, DeleteSynonymMapOptions)

Deletes an existing SynonymMap.

function deleteSynonymMap(synonymMap: string | SynonymMap, options?: DeleteSynonymMapOptions): Promise<void>

Parameters

synonymMap

string | SynonymMap

options
DeleteSynonymMapOptions

Additional optional arguments.

Returns

Promise<void>

getIndex(string, OperationOptions)

Retrieves information about an index.

function getIndex(indexName: string, options?: OperationOptions): Promise<SearchIndex>

Parameters

indexName

string

The name of the index.

options
OperationOptions

Additional optional arguments.

Returns

Promise<SearchIndex>

getIndexStatistics(string, OperationOptions)

Retrieves statistics about an index, such as the count of documents and the size of index storage.

function getIndexStatistics(indexName: string, options?: OperationOptions): Promise<SearchIndexStatistics>

Parameters

indexName

string

The name of the index.

options
OperationOptions

Additional optional arguments.

Returns

getSearchClient<TModel>(string, SearchClientOptions)

Retrieves the SearchClient corresponding to this SearchIndexClient

function getSearchClient<TModel>(indexName: string, options?: SearchClientOptions): SearchClient<TModel>

Parameters

indexName

string

Name of the index

options
SearchClientOptions

SearchClient Options

Returns

SearchClient<TModel>

getServiceStatistics(OperationOptions)

Retrieves statistics about the service, such as the count of documents, index, etc.

function getServiceStatistics(options?: OperationOptions): Promise<SearchServiceStatistics>

Parameters

options
OperationOptions

Additional optional arguments.

Returns

getSynonymMap(string, OperationOptions)

Retrieves information about a SynonymMap.

function getSynonymMap(synonymMapName: string, options?: OperationOptions): Promise<SynonymMap>

Parameters

synonymMapName

string

The name of the SynonymMap.

options
OperationOptions

Additional optional arguments.

Returns

Promise<SynonymMap>

listIndexes(OperationOptions)

Retrieves a list of existing indexes in the service.

function listIndexes(options?: OperationOptions): IndexIterator

Parameters

options
OperationOptions

Options to the list index operation.

Returns

listIndexesNames(OperationOptions)

Retrieves a list of names of existing indexes in the service.

function listIndexesNames(options?: OperationOptions): IndexNameIterator

Parameters

options
OperationOptions

Options to the list index operation.

Returns

listSynonymMaps(OperationOptions)

Retrieves a list of existing SynonymMaps in the service.

function listSynonymMaps(options?: OperationOptions): Promise<SynonymMap[]>

Parameters

options
OperationOptions

Options to the list SynonymMaps operation.

Returns

Promise<SynonymMap[]>

listSynonymMapsNames(OperationOptions)

Retrieves a list of names of existing SynonymMaps in the service.

function listSynonymMapsNames(options?: OperationOptions): Promise<string[]>

Parameters

options
OperationOptions

Options to the list SynonymMaps operation.

Returns

Promise<string[]>