Skip to main content

Actions

The ballerinax/azure.ai.search package exposes the following clients:

ClientPurpose
ClientManages search indexes, indexers, data sources, skillsets, and synonym maps; retrieves service statistics.

Client

Manages search indexes, indexers, data sources, skillsets, and synonym maps; retrieves service statistics.

Configuration

FieldTypeDefaultDescription
httpVersionhttp:HttpVersionHTTP_2_0HTTP protocol version to use for requests.
timeoutdecimal30HTTP request timeout in seconds.
retryConfighttp:RetryConfig()Retry configuration for failed requests.
secureSockethttp:ClientSecureSocket()SSL/TLS configuration.
proxyhttp:ProxyConfig()Proxy server configuration.
validationbooleantrueEnable or disable constraint validation on response payloads.
laxDataBindingbooleantrueEnable lax data binding to ignore unknown fields in responses.

Initializing the client

import ballerinax/azure.ai.search as azureSearch;

configurable string serviceUrl = ?;
configurable string adminKey = ?;

azureSearch:Client searchClient = check new (serviceUrl);

Operations

Index management

indexesCreate

Creates a new search index with the specified field definitions and configuration.

Parameters:

NameTypeRequiredDescription
payloadSearchIndexYesThe index definition including name, fields, analyzers, and optional vector search or semantic settings.
headersIndexesCreateHeadersNoRequest headers. Pass api-key with the admin API key for authentication.
apiVersionstringYesAzure AI Search REST API version (e.g., "2025-09-01").

Returns: SearchIndex|error

Sample code:

azureSearch:SearchIndex index = check searchClient->indexesCreate(
{
name: "hotels",
fields: [
{name: "HotelId", 'type: "Edm.String", key: true, filterable: true},
{name: "HotelName", 'type: "Edm.String", searchable: true, retrievable: true},
{name: "Rating", 'type: "Edm.Int32", filterable: true, sortable: true, facetable: true}
]
},
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "hotels",
"@odata.etag": "\"0x8DCABC123456\"",
"fields": [
{"name": "HotelId", "type": "Edm.String", "key": true, "searchable": false, "filterable": true, "retrievable": true},
{"name": "HotelName", "type": "Edm.String", "key": false, "searchable": true, "filterable": false, "retrievable": true},
{"name": "Rating", "type": "Edm.Int32", "key": false, "searchable": false, "filterable": true, "sortable": true, "facetable": true}
],
"corsOptions": null,
"scoringProfiles": []
}
indexesCreateOrUpdate

Creates a new search index or updates an existing one if it already exists.

Parameters:

NameTypeRequiredDescription
indexNamestringYesThe name of the index to create or update.
headersIndexesCreateOrUpdateHeadersYesRequest headers. Must include Prefer: "return=representation" and api-key.
payloadSearchIndexYesThe full index definition.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndex|error

Sample code:

azureSearch:IndexesCreateOrUpdateHeaders upsertHeaders = {
Prefer: "return=representation",
"api-key": adminKey
};
azureSearch:SearchIndex index = check searchClient->indexesCreateOrUpdate(
"my-index",
upsertHeaders,
{
name: "my-index",
fields: [
{name: "id", 'type: "Edm.String", key: true},
{name: "content", 'type: "Edm.String", searchable: true},
{name: "language", 'type: "Edm.String", filterable: true, facetable: true},
{name: "lastModified", 'type: "Edm.DateTimeOffset", filterable: true, sortable: true}
]
},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-index",
"@odata.etag": "\"0x8DCABC789012\"",
"fields": [
{"name": "id", "type": "Edm.String", "key": true},
{"name": "content", "type": "Edm.String", "searchable": true},
{"name": "language", "type": "Edm.String", "filterable": true, "facetable": true},
{"name": "lastModified", "type": "Edm.DateTimeOffset", "filterable": true, "sortable": true}
]
}
indexesGet

Retrieves the definition of a search index by name.

Parameters:

NameTypeRequiredDescription
indexNamestringYesThe name of the index to retrieve.
headersIndexesGetHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndex|error

Sample code:

azureSearch:SearchIndex index = check searchClient->indexesGet(
"my-index",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-index",
"@odata.etag": "\"0x8DCABC789012\"",
"fields": [
{"name": "id", "type": "Edm.String", "key": true},
{"name": "content", "type": "Edm.String", "searchable": true}
]
}
indexesList

Lists all search indexes defined in the service.

Parameters:

NameTypeRequiredDescription
headersIndexesListHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.
$selectstringNoComma-separated list of fields to include in the response (e.g., "name,etag").

Returns: ListIndexesResult|error

Sample code:

azureSearch:ListIndexesResult result = check searchClient->indexesList(
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"value": [
{"name": "hotels", "@odata.etag": "\"0x8DCABC111\""},
{"name": "my-index", "@odata.etag": "\"0x8DCABC222\""}
]
}
indexesGetStatistics

Returns document count and storage usage statistics for a specific index.

Parameters:

NameTypeRequiredDescription
indexNamestringYesThe name of the index.
headersIndexesGetStatisticsHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: GetIndexStatisticsResult|error

Sample code:

azureSearch:GetIndexStatisticsResult stats = check searchClient->indexesGetStatistics(
"my-index",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"documentCount": 1500,
"storageSize": 2048000,
"vectorIndexSize": 512000
}
indexesAnalyze

Shows how an analyzer or tokenizer breaks a text string into tokens, useful for debugging analyzer configuration.

Parameters:

NameTypeRequiredDescription
indexNamestringYesThe name of the index containing the analyzer to test.
payloadAnalyzeRequestYesThe analyze request specifying the text and the analyzer (or custom tokenizer and token filters).
headersIndexesAnalyzeHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: AnalyzeResult|error

Sample code:

azureSearch:AnalyzeResult result = check searchClient->indexesAnalyze(
"my-index",
{text: "Azure AI Search connector", analyzer: "en.microsoft"},
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"tokens": [
{"token": "azure", "startOffset": 0, "endOffset": 5, "position": 0},
{"token": "ai", "startOffset": 6, "endOffset": 8, "position": 1},
{"token": "search", "startOffset": 9, "endOffset": 15, "position": 2},
{"token": "connector", "startOffset": 16, "endOffset": 25, "position": 3}
]
}
indexesDelete

Deletes a search index and all documents it contains.

Parameters:

NameTypeRequiredDescription
indexNamestringYesThe name of the index to delete.
headersIndexesDeleteHeadersNoRequest headers. Pass api-key for authentication. Optional If-Match for optimistic concurrency control.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->indexesDelete(
"my-index",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Indexer management

indexersCreate

Creates a new indexer that crawls a data source and populates a search index on a schedule.

Parameters:

NameTypeRequiredDescription
payloadSearchIndexerYesThe indexer definition including name, data source name, target index name, and optional schedule.
headersIndexersCreateHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexer|error

Sample code:

azureSearch:SearchIndexer indexer = check searchClient->indexersCreate(
{
name: "blob-indexer",
dataSourceName: "my-blob-datasource",
targetIndexName: "my-index",
schedule: {interval: "PT2H"}
},
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "blob-indexer",
"dataSourceName": "my-blob-datasource",
"targetIndexName": "my-index",
"schedule": {"interval": "PT2H"},
"disabled": false,
"@odata.etag": "\"0x8DCABC101010\""
}
indexersCreateOrUpdate

Creates or updates an indexer, including its schedule, skillset linkage, field mappings, and execution parameters.

Parameters:

NameTypeRequiredDescription
indexerNamestringYesThe name of the indexer to create or update.
headersIndexersCreateOrUpdateHeadersYesRequest headers. Must include Prefer: "return=representation" and api-key.
payloadSearchIndexerYesThe full indexer definition.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexer|error

Sample code:

azureSearch:IndexersCreateOrUpdateHeaders upsertHeaders = {
Prefer: "return=representation",
"api-key": adminKey
};
azureSearch:SearchIndexer indexer = check searchClient->indexersCreateOrUpdate(
"blob-indexer",
upsertHeaders,
{
name: "blob-indexer",
dataSourceName: "my-blob-datasource",
targetIndexName: "my-index",
skillsetName: "my-skillset",
schedule: {interval: "PT1H"},
parameters: {
maxFailedItems: 10,
maxFailedItemsPerBatch: 5,
configuration: {
excludedFileNameExtensions: ".png,.jpg"
}
},
outputFieldMappings: [
{sourceFieldName: "/document/language", targetFieldName: "language"},
{sourceFieldName: "/document/keyphrases", targetFieldName: "keyphrases"}
]
},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "blob-indexer",
"dataSourceName": "my-blob-datasource",
"targetIndexName": "my-index",
"skillsetName": "my-skillset",
"schedule": {"interval": "PT1H"},
"disabled": false,
"@odata.etag": "\"0x8DCABC202020\""
}
indexersGet

Retrieves an indexer definition by name.

Parameters:

NameTypeRequiredDescription
indexerNamestringYesThe name of the indexer to retrieve.
headersIndexersGetHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexer|error

Sample code:

azureSearch:SearchIndexer indexer = check searchClient->indexersGet(
"blob-indexer",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "blob-indexer",
"dataSourceName": "my-blob-datasource",
"targetIndexName": "my-index",
"schedule": {"interval": "PT2H"},
"disabled": false
}
indexersList

Lists all indexers defined in the search service.

Parameters:

NameTypeRequiredDescription
headersIndexersListHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: ListIndexersResult|error

Sample code:

azureSearch:ListIndexersResult result = check searchClient->indexersList(
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"value": [
{"name": "blob-indexer", "dataSourceName": "my-blob-datasource", "targetIndexName": "my-index"},
{"name": "sql-indexer", "dataSourceName": "my-sql-datasource", "targetIndexName": "orders-index"}
]
}
indexersRun

Triggers an indexer to run immediately, outside of its scheduled interval.

Parameters:

NameTypeRequiredDescription
indexerNamestringYesThe name of the indexer to run.
headersIndexersRunHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->indexersRun(
"blob-indexer",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);
indexersReset

Resets the change tracking state of an indexer, causing it to fully re-index all source documents on the next run.

Parameters:

NameTypeRequiredDescription
indexerNamestringYesThe name of the indexer to reset.
headersIndexersResetHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->indexersReset(
"blob-indexer",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);
indexersGetStatus

Returns the current status, last execution result, and execution history of an indexer.

Parameters:

NameTypeRequiredDescription
indexerNamestringYesThe name of the indexer.
headersIndexersGetStatusHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerStatus|error

Sample code:

azureSearch:SearchIndexerStatus status = check searchClient->indexersGetStatus(
"blob-indexer",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"status": "running",
"lastResult": {
"status": "success",
"itemsProcessed": 150,
"itemsFailed": 0,
"startTime": "2025-09-01T10:00:00Z",
"endTime": "2025-09-01T10:05:22Z"
},
"executionHistory": [
{"status": "success", "itemsProcessed": 150, "itemsFailed": 0, "startTime": "2025-09-01T10:00:00Z"},
{"status": "success", "itemsProcessed": 12, "itemsFailed": 0, "startTime": "2025-08-31T10:00:00Z"}
],
"limits": {"maxRunTime": "PT2H"}
}
indexersDelete

Deletes an indexer.

Parameters:

NameTypeRequiredDescription
indexerNamestringYesThe name of the indexer to delete.
headersIndexersDeleteHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->indexersDelete(
"blob-indexer",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Data source management

dataSourcesCreate

Creates a new data source connection to an external data store.

Parameters:

NameTypeRequiredDescription
payloadSearchIndexerDataSourceYesThe data source definition including name, type, credentials, and container.
headersDataSourcesCreateHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerDataSource|error

Sample code:

azureSearch:SearchIndexerDataSource dataSource = check searchClient->dataSourcesCreate(
{
name: "my-blob-datasource",
'type: "azureblob",
credentials: {connectionString: storageConnectionString},
container: {name: storageContainerName}
},
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-blob-datasource",
"type": "azureblob",
"credentials": {"connectionString": "<redacted>"},
"container": {"name": "documents"},
"@odata.etag": "\"0x8DCABC303030\""
}
dataSourcesCreateOrUpdate

Creates or updates a data source connection, including change and deletion detection policies.

Parameters:

NameTypeRequiredDescription
dataSourceNamestringYesThe name of the data source to create or update.
headersDataSourcesCreateOrUpdateHeadersYesRequest headers. Must include Prefer: "return=representation" and api-key.
payloadSearchIndexerDataSourceYesThe full data source definition.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerDataSource|error

Sample code:

azureSearch:DataSourcesCreateOrUpdateHeaders upsertHeaders = {
Prefer: "return=representation",
"api-key": adminKey
};
azureSearch:SearchIndexerDataSource dataSource = check searchClient->dataSourcesCreateOrUpdate(
"my-blob-datasource",
upsertHeaders,
{
name: "my-blob-datasource",
'type: "azureblob",
credentials: {connectionString: storageConnectionString},
container: {name: storageContainerName},
dataDeletionDetectionPolicy: {
"@odata.type": "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy",
softDeleteColumnName: "IsDeleted",
softDeleteMarkerValue: "true"
}
},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-blob-datasource",
"type": "azureblob",
"container": {"name": "documents"},
"dataDeletionDetectionPolicy": {
"@odata.type": "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy",
"softDeleteColumnName": "IsDeleted",
"softDeleteMarkerValue": "true"
},
"@odata.etag": "\"0x8DCABC404040\""
}
dataSourcesGet

Retrieves a data source definition by name.

Parameters:

NameTypeRequiredDescription
dataSourceNamestringYesThe name of the data source to retrieve.
headersDataSourcesGetHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerDataSource|error

Sample code:

azureSearch:SearchIndexerDataSource dataSource = check searchClient->dataSourcesGet(
"my-blob-datasource",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-blob-datasource",
"type": "azureblob",
"credentials": {"connectionString": "<redacted>"},
"container": {"name": "documents"},
"@odata.etag": "\"0x8DCABC404040\""
}
dataSourcesList

Lists all data source connections defined in the search service.

Parameters:

NameTypeRequiredDescription
headersDataSourcesListHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: ListDataSourcesResult|error

Sample code:

azureSearch:ListDataSourcesResult result = check searchClient->dataSourcesList(
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"value": [
{"name": "my-blob-datasource", "type": "azureblob"},
{"name": "my-sql-datasource", "type": "azuresql"}
]
}
dataSourcesDelete

Deletes a data source connection.

Parameters:

NameTypeRequiredDescription
dataSourceNamestringYesThe name of the data source to delete.
headersDataSourcesDeleteHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->dataSourcesDelete(
"my-blob-datasource",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Skillset management

skillsetsCreate

Creates a new skillset containing a pipeline of cognitive enrichment skills applied during indexing.

Parameters:

NameTypeRequiredDescription
payloadSearchIndexerSkillsetYesThe skillset definition including name, description, and list of skills.
headersSkillsetsCreateHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerSkillset|error

Sample code:

azureSearch:SearchIndexerSkillset skillset = check searchClient->skillsetsCreate(
{
name: "my-skillset",
description: "Language detection and key phrase extraction",
skills: [
{
"@odata.type": "#Microsoft.Skills.Text.LanguageDetectionSkill",
name: "languageDetection",
inputs: [{"name": "text", "source": "/document/content"}],
outputs: [{"name": "languageCode", "targetName": "language"}]
},
{
"@odata.type": "#Microsoft.Skills.Text.KeyPhraseExtractionSkill",
name: "keyPhrases",
inputs: [
{"name": "text", "source": "/document/content"},
{"name": "languageCode", "source": "/document/language"}
],
outputs: [{"name": "keyPhrases", "targetName": "keyphrases"}]
}
]
},
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-skillset",
"description": "Language detection and key phrase extraction",
"skills": [
{"@odata.type": "#Microsoft.Skills.Text.LanguageDetectionSkill", "name": "languageDetection"},
{"@odata.type": "#Microsoft.Skills.Text.KeyPhraseExtractionSkill", "name": "keyPhrases"}
],
"@odata.etag": "\"0x8DCABC505050\""
}
skillsetsCreateOrUpdate

Creates or updates a skillset.

Parameters:

NameTypeRequiredDescription
skillsetNamestringYesThe name of the skillset to create or update.
headersSkillsetsCreateOrUpdateHeadersYesRequest headers. Must include Prefer: "return=representation" and api-key.
payloadSearchIndexerSkillsetYesThe full skillset definition.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerSkillset|error

Sample code:

azureSearch:SkillsetsCreateOrUpdateHeaders upsertHeaders = {
Prefer: "return=representation",
"api-key": adminKey
};
azureSearch:SearchIndexerSkillset skillset = check searchClient->skillsetsCreateOrUpdate(
"my-skillset",
upsertHeaders,
{
name: "my-skillset",
skills: [
{
"@odata.type": "#Microsoft.Skills.Text.SentimentSkill",
name: "sentiment",
inputs: [{"name": "text", "source": "/document/content"}],
outputs: [{"name": "score", "targetName": "sentimentScore"}]
}
]
},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-skillset",
"skills": [
{"@odata.type": "#Microsoft.Skills.Text.SentimentSkill", "name": "sentiment"}
],
"@odata.etag": "\"0x8DCABC606060\""
}
skillsetsGet

Retrieves a skillset definition by name.

Parameters:

NameTypeRequiredDescription
skillsetNamestringYesThe name of the skillset to retrieve.
headersSkillsetsGetHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SearchIndexerSkillset|error

Sample code:

azureSearch:SearchIndexerSkillset skillset = check searchClient->skillsetsGet(
"my-skillset",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-skillset",
"skills": [
{"@odata.type": "#Microsoft.Skills.Text.LanguageDetectionSkill", "name": "languageDetection"},
{"@odata.type": "#Microsoft.Skills.Text.KeyPhraseExtractionSkill", "name": "keyPhrases"}
],
"@odata.etag": "\"0x8DCABC505050\""
}
skillsetsList

Lists all skillsets defined in the search service.

Parameters:

NameTypeRequiredDescription
headersSkillsetsListHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: ListSkillsetsResult|error

Sample code:

azureSearch:ListSkillsetsResult result = check searchClient->skillsetsList(
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"value": [
{"name": "my-skillset"},
{"name": "ocr-enrichment-skillset"}
]
}
skillsetsDelete

Deletes a skillset.

Parameters:

NameTypeRequiredDescription
skillsetNamestringYesThe name of the skillset to delete.
headersSkillsetsDeleteHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->skillsetsDelete(
"my-skillset",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Synonym map management

synonymMapsCreate

Creates a new synonym map used to expand or substitute search terms.

Parameters:

NameTypeRequiredDescription
payloadSynonymMapYesThe synonym map definition including name, format ("solr"), and synonyms string.
headersSynonymMapsCreateHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SynonymMap|error

Sample code:

azureSearch:SynonymMap synonymMap = check searchClient->synonymMapsCreate(
{
name: "my-synonyms",
format: "solr",
synonyms: "cloud, azure, sky\nsearch, find, discover\nAI, artificial intelligence"
},
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-synonyms",
"format": "solr",
"synonyms": "cloud, azure, sky\nsearch, find, discover\nAI, artificial intelligence",
"@odata.etag": "\"0x8DCABC707070\""
}
synonymMapsCreateOrUpdate

Creates or updates a synonym map.

Parameters:

NameTypeRequiredDescription
synonymMapNamestringYesThe name of the synonym map to create or update.
headersSynonymMapsCreateOrUpdateHeadersYesRequest headers. Must include Prefer: "return=representation" and api-key.
payloadSynonymMapYesThe full synonym map definition.
apiVersionstringYesAzure AI Search REST API version.

Returns: SynonymMap|error

Sample code:

azureSearch:SynonymMapsCreateOrUpdateHeaders upsertHeaders = {
Prefer: "return=representation",
"api-key": adminKey
};
azureSearch:SynonymMap synonymMap = check searchClient->synonymMapsCreateOrUpdate(
"my-synonyms",
upsertHeaders,
{
name: "my-synonyms",
format: "solr",
synonyms: "cloud, azure, sky\nsearch, find, discover\nAI, artificial intelligence, machine learning"
},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-synonyms",
"format": "solr",
"synonyms": "cloud, azure, sky\nsearch, find, discover\nAI, artificial intelligence, machine learning",
"@odata.etag": "\"0x8DCABC808080\""
}
synonymMapsGet

Retrieves a synonym map definition by name.

Parameters:

NameTypeRequiredDescription
synonymMapNamestringYesThe name of the synonym map to retrieve.
headersSynonymMapsGetHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: SynonymMap|error

Sample code:

azureSearch:SynonymMap synonymMap = check searchClient->synonymMapsGet(
"my-synonyms",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"name": "my-synonyms",
"format": "solr",
"synonyms": "cloud, azure, sky\nsearch, find, discover",
"@odata.etag": "\"0x8DCABC707070\""
}
synonymMapsList

Lists all synonym maps defined in the search service.

Parameters:

NameTypeRequiredDescription
headersSynonymMapsListHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: ListSynonymMapsResult|error

Sample code:

azureSearch:ListSynonymMapsResult result = check searchClient->synonymMapsList(
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"value": [
{"name": "my-synonyms", "format": "solr"},
{"name": "product-synonyms", "format": "solr"}
]
}
synonymMapsDelete

Deletes a synonym map.

Parameters:

NameTypeRequiredDescription
synonymMapNamestringYesThe name of the synonym map to delete.
headersSynonymMapsDeleteHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: error?

Sample code:

check searchClient->synonymMapsDelete(
"my-synonyms",
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Service

getServiceStatistics

Returns service-level counters and limits including index count, document count, storage size, and service tier quotas.

Parameters:

NameTypeRequiredDescription
headersGetServiceStatisticsHeadersNoRequest headers. Pass api-key for authentication.
apiVersionstringYesAzure AI Search REST API version.

Returns: ServiceStatistics|error

Sample code:

azureSearch:ServiceStatistics stats = check searchClient->getServiceStatistics(
headers = {"api-key": adminKey},
apiVersion = "2025-09-01"
);

Sample response:

{
"counters": {
"documentCount": {"usage": 5000, "quota": 1000000},
"indexesCount": {"usage": 3, "quota": 15},
"indexersCount": {"usage": 2, "quota": 15},
"dataSourcesCount": {"usage": 2, "quota": 15},
"storageSize": {"usage": 10485760, "quota": 2147483648},
"synonymMaps": {"usage": 1, "quota": 5},
"skillsetCount": {"usage": 1, "quota": 15}
},
"limits": {
"maxFieldsPerIndex": 1000,
"maxIndexerRunTime": "PT2H",
"maxFileExtractionSize": 16777216,
"maxFileContentCharactersToExtract": 4194304
}
}