Share via


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:

import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents";

const indexClient = new SearchIndexClient("<endpoint>", new AzureKeyCredential("<apiKey>"));

Properties

apiVersion

The API version to use when communicating with the service.

endpoint

The endpoint of the search service

pipeline

A reference to the internal HTTP pipeline for use with raw requests

serviceVersion

The API version to use when communicating with the service.

Methods

analyzeText(string, AnalyzeTextOptions)

Calls an analyzer or tokenizer manually on provided text.

createAlias(SearchAlias, OperationOptions)

Creates a new search alias.

createIndex(SearchIndex, OperationOptions)

Creates a new index.

createKnowledgeBase(KnowledgeBase, CreateKnowledgeBaseOptions)

Creates a new knowledgebase.

createKnowledgeSource(KnowledgeSource, CreateKnowledgeSourceOptions)

Creates a new knowledge source.

createOrUpdateAlias(SearchAlias, CreateOrUpdateAliasOptions)

Creates a new search alias or updates an alias if it already exists.

createOrUpdateIndex(SearchIndex, CreateOrUpdateIndexOptions)

Creates a new index or modifies an existing one.

createOrUpdateKnowledgeBase(string, KnowledgeBase, CreateOrUpdateKnowledgeBaseOptions)

Creates a new knowledge base or updates a knowledge base if it already exists.

createOrUpdateKnowledgeSource(string, KnowledgeSource, CreateOrUpdateKnowledgeSourceOptions)
createOrUpdateSynonymMap(SynonymMap, CreateOrUpdateSynonymMapOptions)

Creates a new SynonymMap or modifies an existing one.

createSynonymMap(SynonymMap, OperationOptions)

Creates a new SynonymMap in a search service.

deleteAlias(SearchAlias, DeleteAliasOptions)

Deletes a search alias and its associated mapping to an index. This operation is permanent, with no recovery option. The mapped index is untouched by this operation.

deleteAlias(string, DeleteAliasOptions)

Deletes a search alias and its associated mapping to an index. This operation is permanent, with no recovery option. The mapped index is untouched by this operation.

deleteIndex(SearchIndex, DeleteIndexOptions)

Deletes an existing index.

deleteIndex(string, DeleteIndexOptions)

Deletes an existing index.

deleteKnowledgeBase(KnowledgeBase, DeleteKnowledgeBaseOptions)

Deletes an existing knowledge base.

deleteKnowledgeBase(string, DeleteKnowledgeBaseOptions)

Deletes an existing knowledge base.

deleteKnowledgeSource(KnowledgeSource, DeleteKnowledgeSourceOptions)

Deletes an existing source.

deleteKnowledgeSource(string, DeleteKnowledgeSourceOptions)

Deletes an existing source.

deleteSynonymMap(string | SynonymMap, DeleteSynonymMapOptions)

Deletes an existing SynonymMap.

getAlias(string, OperationOptions)

Retrieves an alias definition.

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.

getIndexStatsSummary(GetIndexStatsSummaryOptions)

Retrieves a list of existing indexes in the service.

getKnowledgeBase(string, GetKnowledgeBaseOptions)

Retrieves a knowledge base definition.

getKnowledgeRetrievalClient(string, KnowledgeRetrievalClientOptions)

Retrieves the KnowledgeRetrievalClient corresponding to this SearchIndexClient

getKnowledgeSource(string, GetKnowledgeSourceOptions)

Retrieves a knowledge source definition.

getKnowledgeSourceStatus(string, GetKnowledgeSourceStatusOptions)

Returns the current status and synchronization history of a knowledge source.

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.

listAliases(OperationOptions)

Lists all aliases available for a search service.

listIndexes(OperationOptions)

Retrieves a list of existing indexes in the service.

listIndexesNames(OperationOptions)

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

listKnowledgeBases(ListKnowledgeBasesOptions)

Retrieves a list of existing KnowledgeBases in the service.

listKnowledgeSources(ListKnowledgeSourcesOptions)

Retrieves a list of existing KnowledgeSources 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:

import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents";

const indexClient = new SearchIndexClient("<endpoint>", new AzureKeyCredential("<apiKey>"));
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

pipeline

A reference to the internal HTTP pipeline for use with raw requests

pipeline: Pipeline

Property Value

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>

createAlias(SearchAlias, OperationOptions)

Creates a new search alias.

function createAlias(alias: SearchAlias, options?: OperationOptions): Promise<SearchAlias>

Parameters

alias
SearchAlias

The definition of the alias to create.

options
OperationOptions

The options parameters.

Returns

Promise<SearchAlias>

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>

createKnowledgeBase(KnowledgeBase, CreateKnowledgeBaseOptions)

Creates a new knowledgebase.

function createKnowledgeBase(knowledgeBase: KnowledgeBase, options?: CreateKnowledgeBaseOptions): Promise<KnowledgeBase>

Parameters

knowledgeBase
KnowledgeBase

definition of the knowledgebase to create.

options
CreateKnowledgeBaseOptions

options parameters.

Returns

Promise<KnowledgeBase>

createKnowledgeSource(KnowledgeSource, CreateKnowledgeSourceOptions)

Creates a new knowledge source.

function createKnowledgeSource(knowledgeSource: KnowledgeSource, options?: CreateKnowledgeSourceOptions): Promise<KnowledgeSource>

Parameters

knowledgeSource
KnowledgeSource

The definition of the knowledge source to create.

options
CreateKnowledgeSourceOptions

The options parameters.

Returns

Promise<KnowledgeSource>

createOrUpdateAlias(SearchAlias, CreateOrUpdateAliasOptions)

Creates a new search alias or updates an alias if it already exists.

function createOrUpdateAlias(alias: SearchAlias, options?: CreateOrUpdateAliasOptions): Promise<SearchAlias>

Parameters

alias
SearchAlias

The definition of the alias to create or update.

options
CreateOrUpdateAliasOptions

The options parameters.

Returns

Promise<SearchAlias>

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>

createOrUpdateKnowledgeBase(string, KnowledgeBase, CreateOrUpdateKnowledgeBaseOptions)

Creates a new knowledge base or updates a knowledge base if it already exists.

function createOrUpdateKnowledgeBase(knowledgeBaseName: string, knowledgeBase: KnowledgeBase, options?: CreateOrUpdateKnowledgeBaseOptions): Promise<KnowledgeBase>

Parameters

knowledgeBaseName

string

name of the knowledge base to create or update.

knowledgeBase
KnowledgeBase

definition of the knowledge base to create or update.

options
CreateOrUpdateKnowledgeBaseOptions

options parameters.

Returns

Promise<KnowledgeBase>

createOrUpdateKnowledgeSource(string, KnowledgeSource, CreateOrUpdateKnowledgeSourceOptions)

function createOrUpdateKnowledgeSource(sourceName: string, knowledgeSource: KnowledgeSource, options?: CreateOrUpdateKnowledgeSourceOptions): Promise<KnowledgeSource>

Parameters

sourceName

string

knowledgeSource
KnowledgeSource

Returns

Promise<KnowledgeSource>

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>

deleteAlias(SearchAlias, DeleteAliasOptions)

Deletes a search alias and its associated mapping to an index. This operation is permanent, with no recovery option. The mapped index is untouched by this operation.

function deleteAlias(alias: SearchAlias, options?: DeleteAliasOptions): Promise<void>

Parameters

alias
SearchAlias

The alias to delete.

options
DeleteAliasOptions

Additional optional arguments.

Returns

Promise<void>

deleteAlias(string, DeleteAliasOptions)

Deletes a search alias and its associated mapping to an index. This operation is permanent, with no recovery option. The mapped index is untouched by this operation.

function deleteAlias(aliasName: string, options?: DeleteAliasOptions): Promise<void>

Parameters

aliasName

string

Name of the alias to delete.

options
DeleteAliasOptions

Additional optional arguments.

Returns

Promise<void>

deleteIndex(SearchIndex, DeleteIndexOptions)

Deletes an existing index.

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

Parameters

index
SearchIndex

The index to delete.

options
DeleteIndexOptions

Additional optional arguments.

Returns

Promise<void>

deleteIndex(string, DeleteIndexOptions)

Deletes an existing index.

function deleteIndex(indexName: string, options?: DeleteIndexOptions): Promise<void>

Parameters

indexName

string

Name of the index to delete.

options
DeleteIndexOptions

Additional optional arguments.

Returns

Promise<void>

deleteKnowledgeBase(KnowledgeBase, DeleteKnowledgeBaseOptions)

Deletes an existing knowledge base.

function deleteKnowledgeBase(knowledgeBase: KnowledgeBase, options?: DeleteKnowledgeBaseOptions): Promise<void>

Parameters

knowledgeBase
KnowledgeBase

the knowledge base to delete.

options
DeleteKnowledgeBaseOptions

options parameters.

Returns

Promise<void>

deleteKnowledgeBase(string, DeleteKnowledgeBaseOptions)

Deletes an existing knowledge base.

function deleteKnowledgeBase(knowledgeBaseName: string, options?: DeleteKnowledgeBaseOptions): Promise<void>

Parameters

knowledgeBaseName

string

name of the knowledge base to delete.

options
DeleteKnowledgeBaseOptions

options parameters.

Returns

Promise<void>

deleteKnowledgeSource(KnowledgeSource, DeleteKnowledgeSourceOptions)

Deletes an existing source.

function deleteKnowledgeSource(source: KnowledgeSource, options?: DeleteKnowledgeSourceOptions): Promise<void>

Parameters

source
KnowledgeSource

the knowledge source to delete.

options
DeleteKnowledgeSourceOptions

options parameters.

Returns

Promise<void>

deleteKnowledgeSource(string, DeleteKnowledgeSourceOptions)

Deletes an existing source.

function deleteKnowledgeSource(sourceName: string, options?: DeleteKnowledgeSourceOptions): Promise<void>

Parameters

sourceName

string

name of the knowledge source to delete.

options
DeleteKnowledgeSourceOptions

options parameters.

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>

getAlias(string, OperationOptions)

Retrieves an alias definition.

function getAlias(aliasName: string, options?: OperationOptions): Promise<SearchAlias>

Parameters

aliasName

string

The name of the alias to retrieve.

options
OperationOptions

The options parameters.

Returns

Promise<SearchAlias>

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

getIndexStatsSummary(GetIndexStatsSummaryOptions)

Retrieves a list of existing indexes in the service.

function getIndexStatsSummary(options?: GetIndexStatsSummaryOptions): IndexStatisticsSummaryIterator

Parameters

options
GetIndexStatsSummaryOptions

Options to the list index operation.

Returns

getKnowledgeBase(string, GetKnowledgeBaseOptions)

Retrieves a knowledge base definition.

function getKnowledgeBase(knowledgeBaseName: string, options?: GetKnowledgeBaseOptions): Promise<KnowledgeBase>

Parameters

knowledgeBaseName

string

name of the knowledge base to retrieve.

options
GetKnowledgeBaseOptions

options parameters.

Returns

Promise<KnowledgeBase>

getKnowledgeRetrievalClient(string, KnowledgeRetrievalClientOptions)

Retrieves the KnowledgeRetrievalClient corresponding to this SearchIndexClient

function getKnowledgeRetrievalClient(knowledgeBaseName: string, options?: KnowledgeRetrievalClientOptions): KnowledgeRetrievalClient

Parameters

knowledgeBaseName

string

Name of the knowledge base

options
KnowledgeRetrievalClientOptions

KnowledgeRetrievalClient Options

Returns

getKnowledgeSource(string, GetKnowledgeSourceOptions)

Retrieves a knowledge source definition.

function getKnowledgeSource(sourceName: string, options?: GetKnowledgeSourceOptions): Promise<KnowledgeSource>

Parameters

sourceName

string

The name of the knowledge source to retrieve.

options
GetKnowledgeSourceOptions

The options parameters.

Returns

Promise<KnowledgeSource>

getKnowledgeSourceStatus(string, GetKnowledgeSourceStatusOptions)

Returns the current status and synchronization history of a knowledge source.

function getKnowledgeSourceStatus(sourceName: string, options?: GetKnowledgeSourceStatusOptions): Promise<KnowledgeSourceStatus>

Parameters

sourceName

string

The name of the knowledge source for which to retrieve status.

options
GetKnowledgeSourceStatusOptions

The options parameters.

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>

listAliases(OperationOptions)

Lists all aliases available for a search service.

function listAliases(options?: OperationOptions): AliasIterator

Parameters

options
OperationOptions

The options parameters.

Returns

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

listKnowledgeBases(ListKnowledgeBasesOptions)

Retrieves a list of existing KnowledgeBases in the service.

function listKnowledgeBases(options?: ListKnowledgeBasesOptions): KnowledgeBaseIterator

Parameters

options
ListKnowledgeBasesOptions

Options to the list knowledge bases operation.

Returns

listKnowledgeSources(ListKnowledgeSourcesOptions)

Retrieves a list of existing KnowledgeSources in the service.

function listKnowledgeSources(options?: ListKnowledgeSourcesOptions): KnowledgeSourceIterator

Parameters

options
ListKnowledgeSourcesOptions

Options to the list knowledge sources 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[]>