Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@azure/search-documents] Commit Aliases Operations for Search Index Client #20658

Merged
merged 4 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/search/perf-tests/search-documents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"license": "ISC",
"dependencies": {
"@azure/identity": "^2.0.1",
"@azure/search-documents": "11.3.0-beta.6",
"@azure/search-documents": "11.3.0-beta.7",
"@azure/test-utils-perf": "^1.0.0",
"dotenv": "^8.2.0"
},
Expand Down
6 changes: 6 additions & 0 deletions sdk/search/search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 11.3.0-beta.7 (2022-03-08)

### Features Added

- Added new APIs `createAlias`, `createOrUpdateAlias`, `deleteAlias`, `getAlias` & `listAliases` operations to the `SearchIndexClient`.

## 11.3.0-beta.6 (2022-02-08)

### Features Added
Expand Down
2 changes: 1 addition & 1 deletion sdk/search/search-documents/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/search-documents",
"version": "11.3.0-beta.6",
"version": "11.3.0-beta.7",
"description": "Azure client library to use Cognitive Search for node.js and browser.",
"sdk-type": "client",
"main": "dist/index.js",
Expand Down
35 changes: 35 additions & 0 deletions sdk/search/search-documents/review/search-documents.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ export interface CorsOptions {
// @public
export type CountDocumentsOptions = OperationOptions;

// @public
export type CreateAliasOptions = OperationOptions;

// @public
export type CreateDataSourceConnectionOptions = OperationOptions;

Expand All @@ -282,6 +285,11 @@ export type CreateIndexerOptions = OperationOptions;
// @public
export type CreateIndexOptions = OperationOptions;

// @public
export interface CreateOrUpdateAliasOptions extends OperationOptions {
onlyIfUnchanged?: boolean;
}

// @public
export interface CreateorUpdateDataSourceConnectionOptions extends OperationOptions {
onlyIfUnchanged?: boolean;
Expand Down Expand Up @@ -396,6 +404,11 @@ export type DefaultCognitiveServicesAccount = BaseCognitiveServicesAccount & {
odatatype: "#Microsoft.Azure.Search.DefaultCognitiveServices";
};

// @public
export interface DeleteAliasOptions extends OperationOptions {
onlyIfUnchanged?: boolean;
}

// @public
export interface DeleteDataSourceConnectionOptions extends OperationOptions {
onlyIfUnchanged?: boolean;
Expand Down Expand Up @@ -557,6 +570,9 @@ export class GeographyPoint {
toJSON(): Record<string, unknown>;
}

// @public
export type GetAliasOptions = OperationOptions;

// @public
export type GetDataSourceConnectionOptions = OperationOptions;

Expand Down Expand Up @@ -1541,6 +1557,9 @@ export type LimitTokenFilter = BaseTokenFilter & {
// @public
export type LineEnding = string;

// @public
export type ListAliasesOptions = OperationOptions;

// @public
export type ListDataSourceConnectionsOptions = OperationOptions;

Expand Down Expand Up @@ -1809,6 +1828,13 @@ export interface ScoringProfile {
// @public
export type ScoringStatistics = "local" | "global";

// @public
export interface SearchAlias {
etag?: string;
indexes: string[];
name: string;
}

// @public
export class SearchClient<T> implements IndexDocumentsClient<T> {
constructor(endpoint: string, indexName: string, credential: KeyCredential | TokenCredential, options?: SearchClientOptions);
Expand Down Expand Up @@ -1889,18 +1915,23 @@ export class SearchIndexClient {
analyzeText(indexName: string, options: AnalyzeTextOptions): Promise<AnalyzeResult>;
// @deprecated
readonly apiVersion: string;
createAlias(alias: SearchIndexerAlias, options?: CreateAliasOptions): Promise<SearchIndexerAlias>;
createIndex(index: SearchIndex, options?: CreateIndexOptions): Promise<SearchIndex>;
createOrUpdateAlias(alias: SearchIndexerAlias, options?: CreateOrUpdateAliasOptions): Promise<SearchIndexerAlias>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this has changed a few times but at least when I was adding an upsert-like operation to AKV we settled on set instead of createOrUpdate or upsert (so setAlias in this case).

I was also wondering: why is there both createAlias and createOrUpdateAlias - does createAlias throw if the alias already exists? Do we need both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. In search-documents SDK, Yes. We have both create/createOrUpdate operations for all entities such as Indexes, SynonymMaps, DataSourceConnections, etc. To be in sync with that and other language SDKs, the same policy is followed here.
  2. Yes. The create method will throw an error if the entity exists already.

createOrUpdateIndex(index: SearchIndex, options?: CreateOrUpdateIndexOptions): Promise<SearchIndex>;
createOrUpdateSynonymMap(synonymMap: SynonymMap, options?: CreateOrUpdateSynonymMapOptions): Promise<SynonymMap>;
createSynonymMap(synonymMap: SynonymMap, options?: CreateSynonymMapOptions): Promise<SynonymMap>;
deleteAlias(alias: string | SearchIndexerAlias, options?: DeleteAliasOptions): Promise<void>;
deleteIndex(index: string | SearchIndex, options?: DeleteIndexOptions): Promise<void>;
deleteSynonymMap(synonymMap: string | SynonymMap, options?: DeleteSynonymMapOptions): Promise<void>;
readonly endpoint: string;
getAlias(aliasName: string, options?: GetAliasOptions): Promise<SearchIndexerAlias>;
getIndex(indexName: string, options?: GetIndexOptions): Promise<SearchIndex>;
getIndexStatistics(indexName: string, options?: GetIndexStatisticsOptions): Promise<SearchIndexStatistics>;
getSearchClient<T>(indexName: string, options?: SearchClientOptions): SearchClient<T>;
getServiceStatistics(options?: GetServiceStatisticsOptions): Promise<SearchServiceStatistics>;
getSynonymMap(synonymMapName: string, options?: GetSynonymMapsOptions): Promise<SynonymMap>;
listAliases(options?: ListAliasesOptions): Promise<Array<SearchIndexerAlias>>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're sure we don't want an iterator for these? What are the limits of how many can be returned / exist on an account?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have modified the listAliases API to return AliasIterator similar to the the listIndexes API. Thanks

listIndexes(options?: ListIndexesOptions): IndexIterator;
listIndexesNames(options?: ListIndexesOptions): IndexNameIterator;
listSynonymMaps(options?: ListSynonymMapsOptions): Promise<Array<SynonymMap>>;
Expand Down Expand Up @@ -1932,6 +1963,9 @@ export interface SearchIndexer {
targetIndexName: string;
}

// @public
export type SearchIndexerAlias = SearchAlias;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have both SearchAlias and SearchIndexerAlias? Seems like we only need one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it should be SearchIndexAlias. I will fix that. But, why do we have both? The reason is I have renamed the SearchAlias to SearchIndexAlias to be in sync with other naming conventions we followed in the SDK.

And both has to be exposed in the index file. Else, API Extractor will complain about a missing export.


// @public (undocumented)
export interface SearchIndexerCache {
enableReprocessing?: boolean;
Expand Down Expand Up @@ -2291,6 +2325,7 @@ export type SentimentSkillV3 = BaseSearchIndexerSkill & {

// @public
export interface ServiceCounters {
aliasCounter?: ResourceCounter;
dataSourceCounter: ResourceCounter;
documentCounter: ResourceCounter;
indexCounter: ResourceCounter;
Expand Down
2 changes: 1 addition & 1 deletion sdk/search/search-documents/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const SDK_VERSION: string = "11.3.0-beta.6";
export const SDK_VERSION: string = "11.3.0-beta.7";

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading