From 098bf2e9f921deaedad29c0add0c154d8a3eadc4 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 10 Aug 2021 14:04:08 -0700 Subject: [PATCH] [search-documents] Migrated Samples to the new pipeline (#16804) * Migrated Samples to the new pipeline * Formatted the file --- sdk/search/search-documents/package.json | 19 +- .../bufferedSenderAutoFlushSize.ts} | 24 +- .../bufferedSenderAutoFlushTimer.ts} | 22 +- .../bufferedSenderManualFlush.ts} | 22 +- .../dataSourceConnectionOperations.ts | 97 ++++++++ .../samples-dev/indexOperations.ts | 158 ++++++++++++ .../samples-dev/indexerOperations.ts | 119 +++++++++ .../src/utils => samples-dev}/interfaces.ts | 4 + .../src/utils => samples-dev}/setup.ts | 4 + .../samples-dev/skillSetOperations.ts | 127 ++++++++++ .../samples-dev/synonymMapOperations.ts | 71 ++++++ .../samples/javascript/README.md | 133 ---------- .../samples/javascript/sample.env | 6 - .../createDataSourceConnection.js | 37 --- .../createOrUpdateDataSourceConnection.js | 29 --- .../deleteDataSourceConnectionByName.js | 26 -- .../deleteDataSourceConnectionByObject.js | 28 --- .../getDataSourceConnection.js | 36 --- .../listDataSourceConnectionNames.js | 32 --- .../listDataSourceConnections.js | 40 --- .../javascript/src/indexers/createIndexer.js | 30 --- .../src/indexers/createOrUpdateIndexer.js | 26 -- .../src/indexers/deleteIndexerByName.js | 26 -- .../src/indexers/deleteIndexerByObject.js | 29 --- .../javascript/src/indexers/getIndexer.js | 30 --- .../src/indexers/getIndexerStatus.js | 29 --- .../src/indexers/listIndexerNames.js | 28 --- .../javascript/src/indexers/listIndexers.js | 35 --- .../javascript/src/indexers/resetIndexer.js | 23 -- .../javascript/src/indexers/runIndexer.js | 23 -- .../javascript/src/indexes/analyzeText.js | 40 --- .../javascript/src/indexes/createIndex.js | 63 ----- .../src/indexes/createOrUpdateIndex.js | 35 --- .../src/indexes/deleteIndexByName.js | 26 -- .../src/indexes/deleteIndexByObject.js | 28 --- .../javascript/src/indexes/getIndex.js | 28 --- .../src/indexes/getIndexStatistics.js | 28 --- .../src/indexes/getServiceStatistics.js | 52 ---- .../javascript/src/indexes/listIndexNames.js | 30 --- .../javascript/src/indexes/listIndexes.js | 32 --- .../src/skillSets/createOrUpdateSkillset.js | 36 --- .../src/skillSets/createSkillset.js | 55 ----- .../src/skillSets/deleteSkillsetByName.js | 26 -- .../src/skillSets/deleteSkillsetByObject.js | 28 --- .../javascript/src/skillSets/getSkillset.js | 40 --- .../javascript/src/skillSets/listSkillsets.js | 47 ---- .../src/skillSets/listSkillsetsNames.js | 28 --- .../synonymMaps/createOrUpdateSynonymMap.js | 29 --- .../src/synonymMaps/createSynonymMap.js | 29 --- .../src/synonymMaps/deleteSynonymMapByName.js | 26 -- .../synonymMaps/deleteSynonymMapByObject.js | 28 --- .../src/synonymMaps/getSynonymMap.js | 31 --- .../src/synonymMaps/listSynonymMapNames.js | 28 --- .../src/synonymMaps/listSynonymMaps.js | 32 --- .../search-documents/samples/tsconfig.json | 10 - .../samples/typescript/README.md | 146 ----------- .../samples/typescript/sample.env | 6 - .../createDataSourceConnection.ts | 37 --- .../createOrUpdateDataSourceConnection.ts | 31 --- .../deleteDataSourceConnectionByName.ts | 27 --- .../deleteDataSourceConnectionByObject.ts | 30 --- .../getDataSourceConnection.ts | 38 --- .../listDataSourceConnectionNames.ts | 29 --- .../listDataSourceConnections.ts | 42 ---- .../typescript/src/indexers/createIndexer.ts | 31 --- .../src/indexers/createOrUpdateIndexer.ts | 27 --- .../src/indexers/deleteIndexerByName.ts | 27 --- .../src/indexers/deleteIndexerByObject.ts | 30 --- .../typescript/src/indexers/getIndexer.ts | 38 --- .../src/indexers/getIndexerStatus.ts | 30 --- .../src/indexers/listIndexerNames.ts | 29 --- .../typescript/src/indexers/listIndexers.ts | 43 ---- .../typescript/src/indexers/resetIndexer.ts | 24 -- .../typescript/src/indexers/runIndexer.ts | 24 -- .../typescript/src/indexes/analyzeText.ts | 67 ----- .../typescript/src/indexes/createIndex.ts | 65 ----- .../src/indexes/createOrUpdateIndex.ts | 37 --- .../src/indexes/deleteIndexByName.ts | 27 --- .../src/indexes/deleteIndexByObject.ts | 30 --- .../typescript/src/indexes/getIndex.ts | 26 -- .../src/indexes/getIndexStatistics.ts | 30 --- .../src/indexes/getServiceStatistics.ts | 53 ---- .../typescript/src/indexes/listIndexNames.ts | 31 --- .../typescript/src/indexes/listIndexes.ts | 33 --- .../src/skillSets/createOrUpdateSkillset.ts | 37 --- .../src/skillSets/createSkillset.ts | 56 ----- .../src/skillSets/deleteSkillsetByName.ts | 27 --- .../src/skillSets/deleteSkillsetByObject.ts | 30 --- .../typescript/src/skillSets/getSkillset.ts | 45 ---- .../typescript/src/skillSets/listSkillsets.ts | 49 ---- .../src/skillSets/listSkillsetsNames.ts | 29 --- .../synonymMaps/createOrUpdateSynonymMap.ts | 31 --- .../src/synonymMaps/createSynonymMap.ts | 31 --- .../src/synonymMaps/deleteSynonymMapByName.ts | 27 --- .../synonymMaps/deleteSynonymMapByObject.ts | 30 --- .../src/synonymMaps/getSynonymMap.ts | 33 --- .../src/synonymMaps/listSynonymMapNames.ts | 29 --- .../src/synonymMaps/listSynonymMaps.ts | 33 --- .../samples/v11/javascript/README.md | 82 +++++++ .../javascript/bufferedSenderAutoFlushSize.js | 116 +++++++++ .../bufferedSenderAutoFlushTimer.js | 106 ++++++++ .../javascript/bufferedSenderManualFlush.js | 97 ++++++++ .../dataSourceConnectionOperations.js | 82 +++++++ .../samples/v11/javascript/indexOperations.js | 153 ++++++++++++ .../v11/javascript/indexerOperations.js | 114 +++++++++ .../samples/v11/javascript/interfaces.js | 1 + .../samples/{ => v11}/javascript/package.json | 24 +- .../samples/v11/javascript/sample.env | 12 + .../samples/v11/javascript/setup.js | 227 +++++++++++++++++ .../v11/javascript/skillSetOperations.js | 123 ++++++++++ .../v11/javascript/synonymMapOperations.js | 71 ++++++ .../samples/v11/typescript/README.md | 95 ++++++++ .../samples/{ => v11}/typescript/package.json | 29 +-- .../samples/v11/typescript/sample.env | 12 + .../src/bufferedSenderAutoFlushSize.ts | 125 ++++++++++ .../src/bufferedSenderAutoFlushTimer.ts | 115 +++++++++ .../src/bufferedSenderManualFlush.ts | 106 ++++++++ .../src/dataSourceConnectionOperations.ts | 97 ++++++++ .../v11/typescript/src/indexOperations.ts | 158 ++++++++++++ .../v11/typescript/src/indexerOperations.ts | 119 +++++++++ .../samples/v11/typescript/src/interfaces.ts | 39 +++ .../samples/v11/typescript/src/setup.ts | 228 ++++++++++++++++++ .../v11/typescript/src/skillSetOperations.ts | 127 ++++++++++ .../typescript/src/synonymMapOperations.ts | 71 ++++++ .../{ => v11}/typescript/tsconfig.json | 9 +- sdk/search/search-documents/tsconfig.json | 7 +- 126 files changed, 3157 insertions(+), 3111 deletions(-) rename sdk/search/search-documents/{samples/typescript/src/bufferedSender/uploadDocuments/autoFlushSizeBased.ts => samples-dev/bufferedSenderAutoFlushSize.ts} (84%) rename sdk/search/search-documents/{samples/typescript/src/bufferedSender/uploadDocuments/autoFlushTimerBased.ts => samples-dev/bufferedSenderAutoFlushTimer.ts} (84%) rename sdk/search/search-documents/{samples/typescript/src/bufferedSender/uploadDocuments/manualFlush.ts => samples-dev/bufferedSenderManualFlush.ts} (83%) create mode 100644 sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts create mode 100644 sdk/search/search-documents/samples-dev/indexOperations.ts create mode 100644 sdk/search/search-documents/samples-dev/indexerOperations.ts rename sdk/search/search-documents/{samples/typescript/src/utils => samples-dev}/interfaces.ts (95%) rename sdk/search/search-documents/{samples/typescript/src/utils => samples-dev}/setup.ts (99%) create mode 100644 sdk/search/search-documents/samples-dev/skillSetOperations.ts create mode 100644 sdk/search/search-documents/samples-dev/synonymMapOperations.ts delete mode 100644 sdk/search/search-documents/samples/javascript/README.md delete mode 100644 sdk/search/search-documents/samples/javascript/sample.env delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createDataSourceConnection.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createOrUpdateDataSourceConnection.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByName.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByObject.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/getDataSourceConnection.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnectionNames.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnections.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/createIndexer.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/createOrUpdateIndexer.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByName.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByObject.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/getIndexer.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/getIndexerStatus.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/listIndexerNames.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/listIndexers.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/resetIndexer.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexers/runIndexer.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/analyzeText.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/createIndex.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/createOrUpdateIndex.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByName.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByObject.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/getIndex.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/getIndexStatistics.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/getServiceStatistics.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/listIndexNames.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/indexes/listIndexes.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/createOrUpdateSkillset.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/createSkillset.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByName.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByObject.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/getSkillset.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsets.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsetsNames.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/createOrUpdateSynonymMap.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/createSynonymMap.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByName.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByObject.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/getSynonymMap.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMapNames.js delete mode 100644 sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMaps.js delete mode 100644 sdk/search/search-documents/samples/tsconfig.json delete mode 100644 sdk/search/search-documents/samples/typescript/README.md delete mode 100644 sdk/search/search-documents/samples/typescript/sample.env delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createDataSourceConnection.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createOrUpdateDataSourceConnection.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByName.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByObject.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/getDataSourceConnection.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnectionNames.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnections.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/createIndexer.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/createOrUpdateIndexer.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByName.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByObject.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/getIndexer.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/getIndexerStatus.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/listIndexerNames.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/listIndexers.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/resetIndexer.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexers/runIndexer.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/analyzeText.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/createIndex.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/createOrUpdateIndex.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByName.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByObject.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/getIndex.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/getIndexStatistics.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/getServiceStatistics.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/listIndexNames.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/indexes/listIndexes.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/createOrUpdateSkillset.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/createSkillset.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByName.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByObject.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/getSkillset.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsets.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsetsNames.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/createOrUpdateSynonymMap.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/createSynonymMap.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByName.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByObject.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/getSynonymMap.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMapNames.ts delete mode 100644 sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMaps.ts create mode 100644 sdk/search/search-documents/samples/v11/javascript/README.md create mode 100644 sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/indexOperations.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/indexerOperations.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/interfaces.js rename sdk/search/search-documents/samples/{ => v11}/javascript/package.json (50%) create mode 100644 sdk/search/search-documents/samples/v11/javascript/sample.env create mode 100644 sdk/search/search-documents/samples/v11/javascript/setup.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js create mode 100644 sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js create mode 100644 sdk/search/search-documents/samples/v11/typescript/README.md rename sdk/search/search-documents/samples/{ => v11}/typescript/package.json (51%) create mode 100644 sdk/search/search-documents/samples/v11/typescript/sample.env create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/setup.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts create mode 100644 sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts rename sdk/search/search-documents/samples/{ => v11}/typescript/tsconfig.json (69%) diff --git a/sdk/search/search-documents/package.json b/sdk/search/search-documents/package.json index 9ccf63957c0..6b6c92405d7 100644 --- a/sdk/search/search-documents/package.json +++ b/sdk/search/search-documents/package.json @@ -10,14 +10,14 @@ "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", - "build:samples": "dev-tool samples prep && cd dist-samples && tsc -p .", + "build:samples": "echo Obsolete.", + "execute:samples": "dev-tool samples run samples-dev", "build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1", "build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", - "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "clean": "rimraf dist dist-* temp types *.tgz *.log", - "execute:samples": "npm run build:samples && dev-tool samples run dist-samples/javascript dist-samples/typescript/dist/dist-samples/typescript/src/", "extract-api": "tsc -p . && api-extractor run --local", - "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "integration-test:browser": "karma start --single-run", "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace dist-esm/**/*.spec.js --harmony", "integration-test": "npm run integration-test:node && npm run integration-test:browser", @@ -131,5 +131,16 @@ "typescript": "~4.2.0", "util": "^0.12.1", "typedoc": "0.15.2" + }, + "//sampleConfiguration": { + "productName": "Azure Search Documents", + "productSlugs": [ + "azure", + "azure-cognitive-search", + "azure-search" + ], + "requiredResources": { + "Azure Search Documents instance": "https://docs.microsoft.com/azure/search/search-create-service-portal" + } } } diff --git a/sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/autoFlushSizeBased.ts b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts similarity index 84% rename from sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/autoFlushSizeBased.ts rename to sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts index 9e828a577b1..8363c1c1d99 100644 --- a/sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/autoFlushSizeBased.ts +++ b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts @@ -1,3 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Autoflush based on size. + */ + import { SearchIndexingBufferedSender, AzureKeyCredential, @@ -5,8 +12,8 @@ import { GeographyPoint, SearchIndexClient } from "@azure/search-documents"; -import { createIndex, documentKeyRetriever, WAIT_TIME } from "../../utils/setup"; -import { Hotel } from "../../utils/interfaces"; +import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { Hotel } from "./interfaces"; import { delay } from "@azure/core-http"; import * as dotenv from "dotenv"; dotenv.config(); @@ -18,9 +25,9 @@ dotenv.config(); * when the size of the batch is greater than threshold (which is set to 1000) * by default. */ -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; -const TEST_INDEX_NAME = "hotel-live-sample-test3"; +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-4"; function getDocumentsArray(size: number): Hotel[] { const array: Hotel[] = []; @@ -51,7 +58,12 @@ function getDocumentsArray(size: number): Hotel[] { return array; } -export async function main() { +async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-With Auto Flush Sizes Sample`); const credential = new AzureKeyCredential(apiKey); diff --git a/sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/autoFlushTimerBased.ts b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts similarity index 84% rename from sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/autoFlushTimerBased.ts rename to sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts index efda4b3c804..4317f76ef56 100644 --- a/sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/autoFlushTimerBased.ts +++ b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts @@ -1,3 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Autoflush based on timer. + */ + import { SearchIndexingBufferedSender, AzureKeyCredential, @@ -6,8 +13,8 @@ import { SearchIndexClient, DEFAULT_FLUSH_WINDOW } from "@azure/search-documents"; -import { createIndex, documentKeyRetriever, WAIT_TIME } from "../../utils/setup"; -import { Hotel } from "../../utils/interfaces"; +import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { Hotel } from "./interfaces"; import { delay } from "@azure/core-http"; import * as dotenv from "dotenv"; dotenv.config(); @@ -19,11 +26,16 @@ dotenv.config(); * when the time interval is met. The time interval is set to 60000ms * by default. */ -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; -const TEST_INDEX_NAME = "hotel-live-sample-test2"; +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-5"; export async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-With Auto Flush Timer Sample`); const credential = new AzureKeyCredential(apiKey); diff --git a/sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/manualFlush.ts b/sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts similarity index 83% rename from sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/manualFlush.ts rename to sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts index c842049ec85..995e45b236e 100644 --- a/sdk/search/search-documents/samples/typescript/src/bufferedSender/uploadDocuments/manualFlush.ts +++ b/sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts @@ -1,3 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Manual Flush. + */ + import { SearchIndexingBufferedSender, AzureKeyCredential, @@ -5,8 +12,8 @@ import { GeographyPoint, SearchIndexClient } from "@azure/search-documents"; -import { createIndex, documentKeyRetriever, WAIT_TIME } from "../../utils/setup"; -import { Hotel } from "../../utils/interfaces"; +import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { Hotel } from "./interfaces"; import { delay } from "@azure/core-http"; import * as dotenv from "dotenv"; dotenv.config(); @@ -16,11 +23,16 @@ dotenv.config(); * In this sample, the autoFlush is set to false. i.e. the user * wants to call the flush manually. */ -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; -const TEST_INDEX_NAME = "hotel-live-sample-test1"; +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-6"; export async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-Without AutoFlush Sample`); const credential = new AzureKeyCredential(apiKey); diff --git a/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts b/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts new file mode 100644 index 00000000000..20724b11029 --- /dev/null +++ b/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the DataSource Connection Operations. + */ + +import { + SearchIndexerClient, + AzureKeyCredential, + SearchIndexerDataSourceConnection +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const connectionString = process.env.CONNECTION_STRING || ""; +const dataSourceConnectionName = "example-ds-connection-sample-1"; + +async function createDataSourceConnection( + dataSourceConnectionName: string, + client: SearchIndexerClient +) { + console.log(`Creating DS Connection Operation`); + const dataSourceConnection: SearchIndexerDataSourceConnection = { + name: dataSourceConnectionName, + description: "My Data Source 1", + type: "cosmosdb", + container: { + name: "my-container-1" + }, + connectionString + }; + await client.createDataSourceConnection(dataSourceConnection); +} + +async function getAndUpdateDataSourceConnection( + dataSourceConnectionName: string, + client: SearchIndexerClient +) { + console.log(`Get And Update DS Connection Operation`); + const ds: SearchIndexerDataSourceConnection = await client.getDataSourceConnection( + dataSourceConnectionName + ); + ds.container.name = "Listings_5K_KingCounty_WA"; + console.log(`Updating Container Name of Datasource Connection ${dataSourceConnectionName}`); + await client.createOrUpdateDataSourceConnection(ds); +} + +async function listDataSourceConnections(client: SearchIndexerClient) { + console.log(`List DS Connection Operation`); + const listOfDataSourceConnections: Array = await client.listDataSourceConnections(); + + console.log(`List of Data Source Connections`); + console.log(`*******************************`); + for (let ds of listOfDataSourceConnections) { + console.log(`Name: ${ds.name}`); + console.log(`Description: ${ds.description}`); + console.log(`Connection String: ${ds.connectionString}`); + console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); + console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); + console.log(`Etag: ${ds.etag}`); + console.log(`DataContainer`); + console.log(`\tName: ${ds.container.name}`); + console.log(`\tQuery: ${ds.container.query}`); + console.log(); + } +} + +async function deleteDataSourceConnection( + dataSourceConnectionName: string, + client: SearchIndexerClient +) { + console.log(`Deleting DS Connection Operation`); + await client.deleteDataSourceConnection(dataSourceConnectionName); +} + +async function main() { + console.log(`Running DS Connection Operations Sample....`); + if (!endpoint || !apiKey || !connectionString) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createDataSourceConnection(dataSourceConnectionName, client); + await getAndUpdateDataSourceConnection(dataSourceConnectionName, client); + await listDataSourceConnections(client); + } finally { + await deleteDataSourceConnection(dataSourceConnectionName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples-dev/indexOperations.ts b/sdk/search/search-documents/samples-dev/indexOperations.ts new file mode 100644 index 00000000000..89aec8a8ef6 --- /dev/null +++ b/sdk/search/search-documents/samples-dev/indexOperations.ts @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Index Operations. + */ + +import { + SearchIndexClient, + AzureKeyCredential, + SearchIndex, + SearchIndexStatistics +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const indexName = "example-index-sample-1"; + +async function createIndex(indexName: string, client: SearchIndexClient) { + console.log(`Creating Index Operation`); + const index: SearchIndex = { + name: indexName, + fields: [ + { + type: "Edm.String", + name: "id", + key: true + }, + { + type: "Edm.Double", + name: "awesomenessLevel", + sortable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.String", + name: "description", + searchable: true + }, + { + type: "Edm.ComplexType", + name: "details", + fields: [ + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true + } + ] + }, + { + type: "Edm.Int32", + name: "hiddenWeight", + hidden: true + } + ] + }; + await client.createIndex(index); +} + +async function getAndUpdateIndex(indexName: string, client: SearchIndexClient) { + console.log(`Get And Update Index Operation`); + const index: SearchIndex = await client.getIndex(indexName); + index.fields.push({ + type: "Edm.DateTimeOffset", + name: "lastUpdatedOn", + filterable: true + }); + await client.createOrUpdateIndex(index); +} + +async function getIndexStatistics(indexName: string, client: SearchIndexClient) { + console.log(`Get Index Statistics Operation`); + const statistics: SearchIndexStatistics = await client.getIndexStatistics(indexName); + console.log(`Document Count: ${statistics.documentCount}`); + console.log(`Storage Size: ${statistics.storageSize}`); +} + +async function getServiceStatistics(client: SearchIndexClient) { + console.log(`Get Service Statistics Operation`); + const { counters, limits } = await client.getServiceStatistics(); + console.log(`Counters`); + console.log(`========`); + console.log(`\tDocument Counter`); + console.log(`\t\tUsage: ${counters.documentCounter.usage}`); + console.log(`\t\tQuota: ${counters.documentCounter.quota}`); + console.log(`\tIndex Counter`); + console.log(`\t\tUsage: ${counters.indexCounter.usage}`); + console.log(`\t\tQuota: ${counters.indexCounter.quota}`); + console.log(`\tIndexer Counter`); + console.log(`\t\tUsage: ${counters.indexerCounter.usage}`); + console.log(`\t\tQuota: ${counters.indexerCounter.quota}`); + console.log(`\tData Source Counter`); + console.log(`\t\tUsage: ${counters.dataSourceCounter.usage}`); + console.log(`\t\tQuota: ${counters.dataSourceCounter.quota}`); + console.log(`\tStorage Size Counter`); + console.log(`\t\tUsage: ${counters.storageSizeCounter.usage}`); + console.log(`\t\tQuota: ${counters.storageSizeCounter.quota}`); + console.log(`\tSynonym Map Counter`); + console.log(`\t\tUsage: ${counters.synonymMapCounter.usage}`); + console.log(`\t\tQuota: ${counters.synonymMapCounter.quota}`); + console.log(); + console.log(`Limits`); + console.log(`======`); + console.log(`\tMax Fields Per Index: ${limits.maxFieldsPerIndex}`); + console.log(`\tMax Field Nesting Depth Per Index: ${limits.maxFieldNestingDepthPerIndex}`); + console.log( + `\tMax Complex Collection Fields Per Index: ${limits.maxComplexCollectionFieldsPerIndex}` + ); + console.log( + `\tMax Complex Objects In Collections Per Document: ${limits.maxComplexObjectsInCollectionsPerDocument}` + ); +} + +async function listIndexes(client: SearchIndexClient) { + console.log(`List Indexes Operation`); + const result = await client.listIndexes(); + let listOfIndexes = await result.next(); + + console.log(`List of Indexes`); + console.log(`***************`); + while (!listOfIndexes.done) { + console.log(`Name: ${listOfIndexes.value.name}`); + console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); + console.log(); + listOfIndexes = await result.next(); + } +} + +async function deleteIndex(indexName: string, client: SearchIndexClient) { + console.log(`Deleting Index Operation`); + await client.deleteIndex(indexName); +} + +async function main() { + console.log(`Running Index Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createIndex(indexName, client); + await getAndUpdateIndex(indexName, client); + await getIndexStatistics(indexName, client); + await getServiceStatistics(client); + await listIndexes(client); + } finally { + await deleteIndex(indexName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples-dev/indexerOperations.ts b/sdk/search/search-documents/samples-dev/indexerOperations.ts new file mode 100644 index 00000000000..f1530883c88 --- /dev/null +++ b/sdk/search/search-documents/samples-dev/indexerOperations.ts @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Indexer Operations. + */ + +import { + SearchIndexerClient, + AzureKeyCredential, + SearchIndexer, + SearchIndexerStatus +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const dataSourceName = process.env.DATA_SOURCE_NAME || ""; +const targetIndexName = process.env.TARGET_INDEX_NAME || ""; + +const indexerName = "example-indexer-sample-1"; + +async function createIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Creating Indexer Operation`); + const indexer: SearchIndexer = { + name: indexerName, + description: "Description for Sample Indexer", + dataSourceName, + targetIndexName, + isDisabled: false + }; + await client.createIndexer(indexer); +} + +async function getAndUpdateIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Get And Update Indexer Operation`); + const indexer: SearchIndexer = await client.getIndexer(indexerName); + indexer.isDisabled = true; + await client.createOrUpdateIndexer(indexer); + indexer.isDisabled = false; + await client.createOrUpdateIndexer(indexer); +} + +async function getIndexerStatus(indexerName: string, client: SearchIndexerClient) { + console.log(`Get Indexer Status Operation`); + const indexerStatus: SearchIndexerStatus = await client.getIndexerStatus(indexerName); + console.log(`Status: ${indexerStatus.status}`); + console.log(`Limits`); + console.log(`******`); + console.log( + `MaxDocumentContentCharactersToExtract: ${indexerStatus.limits.maxDocumentContentCharactersToExtract}` + ); + console.log(`MaxDocumentExtractionSize: ${indexerStatus.limits.maxDocumentExtractionSize}`); + console.log(`MaxRunTime: ${indexerStatus.limits.maxRunTime}`); +} + +async function listIndexers(client: SearchIndexerClient) { + console.log(`List Indexers Operation`); + const listOfIndexers: Array = await client.listIndexers(); + + console.log(`\tList of Indexers`); + console.log(`\t****************`); + for (let indexer of listOfIndexers) { + console.log(`Name: ${indexer.name}`); + console.log(`Description: ${indexer.description}`); + console.log(`Data Source Name: ${indexer.dataSourceName}`); + console.log(`Skillset Name: ${indexer.skillsetName}`); + console.log(`Target Index Name: ${indexer.targetIndexName}`); + console.log(`Indexing Schedule`); + console.log(`\tInterval: ${indexer.schedule?.interval}`); + console.log(`\tStart Time: ${indexer.schedule?.startTime}`); + console.log(`Is Disabled: ${indexer.isDisabled}`); + console.log(`ETag: ${indexer.etag}`); + console.log(`Parameters`); + console.log(`\tBatch Size: ${indexer.parameters?.batchSize}`); + console.log(`\tMax Failed Items: ${indexer.parameters?.maxFailedItems}`); + console.log(`\tMax Failed Items Per Batch: ${indexer.parameters?.maxFailedItemsPerBatch}`); + console.log(); + } +} + +async function resetIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Reset Indexer Operation`); + await client.resetIndexer(indexerName); +} + +async function deleteIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Deleting Indexer Operation`); + await client.deleteIndexer(indexerName); +} + +async function runIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Run Indexer Operation`); + await client.runIndexer(indexerName); +} + +async function main() { + console.log(`Running Indexer Operations Sample....`); + if (!endpoint || !apiKey || !dataSourceName || !targetIndexName) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createIndexer(indexerName, client); + await getAndUpdateIndexer(indexerName, client); + await getIndexerStatus(indexerName, client); + await listIndexers(client); + await resetIndexer(indexerName, client); + await runIndexer(indexerName, client); + } finally { + await deleteIndexer(indexerName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/typescript/src/utils/interfaces.ts b/sdk/search/search-documents/samples-dev/interfaces.ts similarity index 95% rename from sdk/search/search-documents/samples/typescript/src/utils/interfaces.ts rename to sdk/search/search-documents/samples-dev/interfaces.ts index 35a81e35132..1230fa50a70 100644 --- a/sdk/search/search-documents/samples/typescript/src/utils/interfaces.ts +++ b/sdk/search/search-documents/samples-dev/interfaces.ts @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +/** + * @summary Defines the Hotel Interface. + */ + import { GeographyPoint } from "@azure/search-documents"; export interface Hotel { diff --git a/sdk/search/search-documents/samples/typescript/src/utils/setup.ts b/sdk/search/search-documents/samples-dev/setup.ts similarity index 99% rename from sdk/search/search-documents/samples/typescript/src/utils/setup.ts rename to sdk/search/search-documents/samples-dev/setup.ts index 1b0c230e71f..d5478f2d986 100644 --- a/sdk/search/search-documents/samples/typescript/src/utils/setup.ts +++ b/sdk/search/search-documents/samples-dev/setup.ts @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +/** + * @summary Defines the utility methods. + */ + import { SearchIndexClient, SearchIndex, KnownAnalyzerNames } from "@azure/search-documents"; import { Hotel } from "./interfaces"; diff --git a/sdk/search/search-documents/samples-dev/skillSetOperations.ts b/sdk/search/search-documents/samples-dev/skillSetOperations.ts new file mode 100644 index 00000000000..8bf587fde6e --- /dev/null +++ b/sdk/search/search-documents/samples-dev/skillSetOperations.ts @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Skillset Operations. + */ + +import { + SearchIndexerClient, + AzureKeyCredential, + SearchIndexerSkillset +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; + +const skillsetName = "example-skillset-sample-1"; + +async function createSkillset(skillsetName: string, client: SearchIndexerClient) { + console.log(`Creating Skillset Operation`); + const skillset: SearchIndexerSkillset = { + name: skillsetName, + description: `Skillset description`, + skills: [ + { + odatatype: "#Microsoft.Skills.Text.EntityRecognitionSkill", + inputs: [ + { + name: "text", + source: "/document/merged_content" + }, + { + name: "languageCode", + source: "/document/language" + } + ], + outputs: [ + { + name: "persons", + targetName: "people" + }, + { + name: "organizations", + targetName: "organizations" + }, + { + name: "locations", + targetName: "locations" + } + ] + } + ] + }; + await client.createSkillset(skillset); +} + +async function getAndUpdateSkillset(skillsetName: string, client: SearchIndexerClient) { + console.log(`Get And Update Skillset Operation`); + const skillset: SearchIndexerSkillset = await client.getSkillset(skillsetName); + + skillset.skills[0].outputs = [ + { + name: "persons", + targetName: "people" + }, + { + name: "organizations", + targetName: "organizations" + } + ]; + + await client.createOrUpdateSkillset(skillset); +} + +async function listSkillsets(client: SearchIndexerClient) { + console.log(`List Skillset Operation`); + const listOfSkillsets: Array = await client.listSkillsets(); + + console.log(`\tList of Skillsets`); + console.log(`\t******************`); + for (let skillset of listOfSkillsets) { + console.log(`Name: ${skillset.name}`); + console.log(`Description: ${skillset.description}`); + console.log(`Skills`); + console.log(`******`); + for (let skill of skillset.skills) { + console.log(`ODataType: ${skill.odatatype}`); + console.log(`Inputs`); + for (let input of skill.inputs) { + console.log(`\tName: ${input.name}`); + console.log(`\tSource: ${input.source}`); + } + console.log(`Outputs`); + for (let output of skill.outputs) { + console.log(`\tName: ${output.name}`); + console.log(`\tTarget Name: ${output.targetName}`); + } + } + } +} + +async function deleteSkillset(skillsetName: string, client: SearchIndexerClient) { + console.log(`Deleting Skillset Operation`); + await client.deleteSkillset(skillsetName); +} + +async function main() { + console.log(`Running Skillset Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createSkillset(skillsetName, client); + await getAndUpdateSkillset(skillsetName, client); + await listSkillsets(client); + } finally { + await deleteSkillset(skillsetName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples-dev/synonymMapOperations.ts b/sdk/search/search-documents/samples-dev/synonymMapOperations.ts new file mode 100644 index 00000000000..bc3dcac9681 --- /dev/null +++ b/sdk/search/search-documents/samples-dev/synonymMapOperations.ts @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SynonymMap Operations. + */ + +import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const synonymMapName = "example-synonymmap-sample-1"; + +async function createSynonymMap(synonymMapName: string, client: SearchIndexClient) { + console.log(`Creating SynonymMap Operation`); + const sm: SynonymMap = { + name: synonymMapName, + synonyms: ["United States, United States of America => USA", "Washington, Wash. => WA"] + }; + await client.createSynonymMap(sm); +} + +async function getAndUpdateSynonymMap(synonymMapName: string, client: SearchIndexClient) { + console.log(`Get And Update SynonymMap Operation`); + const sm: SynonymMap = await client.getSynonymMap(synonymMapName); + console.log(`Update synonyms Synonym Map my-synonymmap`); + sm.synonyms.push("Florida, Fld. => FL"); + await client.createOrUpdateSynonymMap(sm); +} + +async function listSynonymMaps(client: SearchIndexClient) { + console.log(`List SynonymMaps Operation`); + const listOfSynonymMaps: Array = await client.listSynonymMaps(); + + console.log(`List of SynonymMaps`); + console.log(`*******************`); + for (let sm of listOfSynonymMaps) { + console.log(`Name: ${sm.name}`); + console.log(`Synonyms`); + for (let synonym of sm.synonyms) { + console.log(synonym); + } + } +} + +async function deleteSynonymMap(synonymMapName: string, client: SearchIndexClient) { + console.log(`Deleting SynonymMap Operation`); + await client.deleteSynonymMap(synonymMapName); +} + +async function main() { + console.log(`Running Index Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createSynonymMap(synonymMapName, client); + await getAndUpdateSynonymMap(synonymMapName, client); + await listSynonymMaps(client); + } finally { + await deleteSynonymMap(synonymMapName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/javascript/README.md b/sdk/search/search-documents/samples/javascript/README.md deleted file mode 100644 index d8c9d48dd99..00000000000 --- a/sdk/search/search-documents/samples/javascript/README.md +++ /dev/null @@ -1,133 +0,0 @@ -# Azure Cognitive Search client library samples for JavaScript - -These sample programs show how to use the JavaScript client libraries for Azure Cognitive Search in some common scenarios. - -| **File Name** | **Description** | -| ---------------------------- | ------------------------ | -| **Data Source Connections** | -| [createDataSourceConnection.js][createDataSourceConnection] | Creates a Datasource Connection | -| [createOrUpdateDataSourceConnection.js][createOrUpdateDataSourceConnection] | Updates a Datasource Connection | -| [deleteDataSourceConnectionByName.js][deleteDataSourceConnectionByName] | Deletes Datasource Connection by Name | -| [deleteDataSourceConnectionByObject.js][deleteDataSourceConnectionByObject] | Deletes Datasource Connection by Object | -| [getDataSourceConnection.js][getDataSourceConnection] | Gets a Datasource Connection | -| [listDataSourceConnectionNames.js][listDataSourceConnectionNames] | List names of Datasource Connections | -| [listDataSourceConnections.js][listDataSourceConnections] | List Datasource Connections | -| **Indexers** | -| [createIndexer.js][createIndexer] | Creates an Indexer | -| [createOrUpdateIndexer.js][createOrUpdateIndexer] | Updates an Indexer | -| [deleteIndexerByName.js][deleteIndexerByName] | Deletes Indexer by Name | -| [deleteIndexerByObject.js][deleteIndexerByObject] | Deletes Indexer by Object | -| [getIndexer.js][getIndexer] | Gets an Indexer | -| [getIndexerStatus.js][getIndexerStatus] | Gets the status of an Indexer | -| [listIndexerNames.js][listIndexerNames] | List names of Indexers | -| [listIndexers.js][listIndexers] | List Indexers | -| [resetIndexer.js][resetIndexer] | Resets an Indexer | -| [runIndexer.js][runIndexer] | Runs an Indexer | -| **Indexes** | -| [analyzeText.js][analyzeText] | Analyzes a given text | -| [createIndex.js][createIndex] | Creates an Index | -| [createOrUpdateIndex.js][createOrUpdateIndex] | Updates an Index | -| [deleteIndexByName.js][deleteIndexByName] | Deletes Index by Name | -| [deleteIndexByObject.js][deleteIndexByObject] | Deletes Index by Object | -| [getIndex.js][getIndex] | Gets an Index | -| [getIndexStatistics.js][getIndexStatistics] | Gets the Statistics of an Index | -| [listIndexes.js][listIndexes] | List Indexes | -| [listIndexNames.js][listIndexNames] | List Names of Indexes | -| **Skillsets** | -| [createOrUpdateSkillset.js][createOrUpdateSkillset] | Updates a skillset | -| [createSkillset.js][createSkillset] | Creates a skillset | -| [deleteSkillsetByName.js][deleteSkillsetByName] | Deletes a Skillset by Name | -| [deleteSkillsetByObject.js][deleteSkillsetByObject] | Deletes a Skillset by Object | -| [getSkillset.js][getSkillset] | Gets a skillset | -| [listSkillsets.js][listSkillsets] | List all skillsets | -| [listSkillsetsNames.js][listSkillsetsNames] | List names of skillsets | -| **SynonymMaps** | -| [createOrUpdateSynonymMap.js][createOrUpdateSynonymMap] | Updates a synonym map | -| [createSynonymMap.js][createSynonymMap] | Creates a synonym map | -| [deleteSynonymMapByName.js][deleteSynonymMapByName] | Deletes a synonym map by Name | -| [deleteSynonymMapByObject.js][deleteSynonymMapByObject] | Deletes a synonym map by object | -| [getSynonymMap.js][getSynonymMap] | Gets a synonym map | -| [listSynonymMapNames.js][listSynonymMapNames] | List names of synonym maps | -| [listSynonymMaps.js][listSynonymMaps] | List all synonym maps | - -## Prerequisites - -The samples are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). - -You need [an Azure subscription][freesub] and [an Azure Cognitive Search service][search_resource] to run these sample programs. Samples retrieve credentials to access the Azure Cognitive Search endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -3. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node readonlyQuery.js -``` - -Alternatively, run a single sample with the correct environment variables set (step 3 is not required if you do this), for example (cross-platform): - -```bash -npx cross-env SEARCH_API_ENDPOINT="" SEARCH_API_KEY="" node readonlyQuery.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[readonly]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/readonlyQuery.js -[apiref]: https://aka.ms/azsdk/js/search/docs -[search_resource]: https://docs.microsoft.com/azure/search/search-create-service-portal -[freesub]: https://azure.microsoft.com/free/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/README.md -[createDataSourceConnection]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createDataSourceConnection.js -[createOrUpdateDataSourceConnection]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createOrUpdateDataSourceConnection.js -[deleteDataSourceConnectionByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByName.js -[deleteDataSourceConnectionByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByObject.js -[getDataSourceConnection]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/getDataSourceConnection.js -[listDataSourceConnectionNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnectionNames.js -[listDataSourceConnections]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnections.js -[createIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/createIndexer.js -[createOrUpdateIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/createOrUpdateIndexer.js -[deleteIndexerByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByName.js -[deleteIndexerByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByObject.js -[getIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/getIndexer.js -[getIndexerStatus]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/getIndexerStatus.js -[listIndexerNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/listIndexerNames.js -[listIndexers]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/listIndexers.js -[resetIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/resetIndexer.js -[runIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexers/runIndexer.js -[analyzeText]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/analyzeText.js -[createIndex]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/createIndex.js -[createOrUpdateIndex]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/createOrUpdateIndex.js -[deleteIndexByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByName.js -[deleteIndexByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByObject.js -[getIndex]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/getIndex.js -[getIndexStatistics]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/getIndexStatistics.js -[listIndexes]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/listIndexes.js -[listIndexNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/indexes/listIndexNames.js -[createOrUpdateSkillset]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/createOrUpdateSkillset.js -[createSkillset]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/createSkillset.js -[deleteSkillsetByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByName.js -[deleteSkillsetByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByObject.js -[getSkillset]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/getSkillset.js -[listSkillsets]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsets.js -[listSkillsetsNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsetsNames.js -[createOrUpdateSynonymMap]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/createOrUpdateSynonymMap.js -[createSynonymMap]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/createSynonymMap.js -[deleteSynonymMapByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByName.js -[deleteSynonymMapByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByObject.js -[getSynonymMap]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/getSynonymMap.js -[listSynonymMapNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMapNames.js -[listSynonymMaps]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMaps.js diff --git a/sdk/search/search-documents/samples/javascript/sample.env b/sdk/search/search-documents/samples/javascript/sample.env deleted file mode 100644 index 7c90b03954f..00000000000 --- a/sdk/search/search-documents/samples/javascript/sample.env +++ /dev/null @@ -1,6 +0,0 @@ -# Used in most samples. Retrieve these values from a Cognitive Search instance -# in the Azure Portal. - -SEARCH_API_KEY= -SEARCH_API_ENDPOINT=https://.search.windows.net -INDEX_NAME=hotels-sample-index diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createDataSourceConnection.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createDataSourceConnection.js deleted file mode 100644 index 5fc8d09f33f..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createDataSourceConnection.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Datasource Connection Sample....`); - - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const dataSourceConnection = { - name: "my-data-source-2", - description: "My Data Source 1", - type: "cosmosdb", - container: { - name: "my-container-1" - }, - connectionString: - "AccountEndpoint=https://hotels-docbb.documents.azure.com:443/;AccountKey=4UPsNZyFAjgZ1tzHPGZaxS09XcwLrIawbXBWk6IixcxJoSePTcjBn0mi53XiKWu8MaUgowUhIovOv7kjksqAug==;Database=SampleData" - }; - await client.createDataSourceConnection(dataSourceConnection); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createOrUpdateDataSourceConnection.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createOrUpdateDataSourceConnection.js deleted file mode 100644 index 2eccf9cb7d4..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/createOrUpdateDataSourceConnection.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running CreateOrUpdate Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Datasource Connection my-data-source-2`); - const ds = await client.getDataSourceConnection("my-data-source-2") - ds.container.name = "Listings_5K_KingCounty_WA"; - console.log(`Updating Container Name of Datasource Connection my-data-source-2`); - await client.createOrUpdateDataSourceConnection(ds); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByName.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByName.js deleted file mode 100644 index 3f7b8f1e003..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByName.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Datasource Connection my-data-source-2`); - await client.deleteDataSourceConnection("my-data-source-2") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByObject.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByObject.js deleted file mode 100644 index f52a9867309..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/deleteDataSourceConnectionByObject.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Datasource Connection my-data-source-2`); - const ds = await client.getDataSourceConnection("my-data-source-2"); - console.log(`Deleting Datasource Connection my-data-source-2`); - await client.deleteDataSourceConnection(ds); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/getDataSourceConnection.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/getDataSourceConnection.js deleted file mode 100644 index f7d54dbf149..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/getDataSourceConnection.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Datasource Connection my-data-source-2`); - const ds = await client.getDataSourceConnection("my-data-source-2") - console.log(`Name: ${ds.name}`); - console.log(`Description: ${ds.description}`); - console.log(`Connection String: ${ds.connectionString}`); - console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); - console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); - console.log(`Etag: ${ds.etag}`); - console.log(`DataContainer`); - console.log(`\tName: ${ds.container.name}`); - console.log(`\tQuery: ${ds.container.query}`); - console.log(); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnectionNames.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnectionNames.js deleted file mode 100644 index 9700e9564e9..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnectionNames.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); - -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Datasource Connection Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfDataSourceConnectionNames = await client.listDataSourceConnectionsNames(); - - console.log(`Names of Data Source Connections`); - console.log(`*******************************`); - for(const ds of listOfDataSourceConnectionNames) { - console.log(ds); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnections.js b/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnections.js deleted file mode 100644 index 485ee305f12..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/dataSourceConnections/listDataSourceConnections.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Datasource Connections Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfDataSourceConnections = await client.listDataSourceConnections(); - - console.log(`List of Data Source Connections`); - console.log(`*******************************`) - for(const ds of listOfDataSourceConnections) { - console.log(`Name: ${ds.name}`); - console.log(`Description: ${ds.description}`); - console.log(`Connection String: ${ds.connectionString}`); - console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); - console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); - console.log(`Etag: ${ds.etag}`); - console.log(`DataContainer`); - console.log(`\tName: ${ds.container.name}`); - console.log(`\tQuery: ${ds.container.query}`); - console.log(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/createIndexer.js b/sdk/search/search-documents/samples/javascript/src/indexers/createIndexer.js deleted file mode 100644 index 44a22f26f2d..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/createIndexer.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const indexer = { - name: "my-azure-indexer-1", - description: "Description for Sample Indexer", - dataSourceName: "realestate-us-sample", - targetIndexName: "realestate-us-sample-index", - isDisabled: false - }; - - await client.createIndexer(indexer); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/createOrUpdateIndexer.js b/sdk/search/search-documents/samples/javascript/src/indexers/createOrUpdateIndexer.js deleted file mode 100644 index 13585efdb33..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/createOrUpdateIndexer.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Or Update Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer my-azure-indexer-1`); - const indexer = await client.getIndexer("my-azure-indexer-1"); - console.log(`Updating isDisabled status of Indexer my-azure-indexer-1`); - indexer.isDisabled = true; - await client.createOrUpdateIndexer(indexer); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByName.js b/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByName.js deleted file mode 100644 index c8a4ae55ab2..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByName.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Indexer my-azure-indexer-1`); - await client.deleteIndexer("my-azure-indexer-1") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByObject.js b/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByObject.js deleted file mode 100644 index 89a0d3d1e29..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/deleteIndexerByObject.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexer -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer my-azure-indexer-1`); - const indexer = await client.getIndexer("my-azure-indexer-1"); - console.log(`Deleting Indexer my-azure-indexer-1`); - await client.deleteIndexer(indexer); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/getIndexer.js b/sdk/search/search-documents/samples/javascript/src/indexers/getIndexer.js deleted file mode 100644 index 79ddd7ca1c7..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/getIndexer.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential, SearchIndexer } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer my-azure-indexer-1`); - const indexer = await client.getIndexer("my-azure-indexer-1"); - console.log(`Name: ${indexer.name}`); - console.log(`Description: ${indexer.description}`); - console.log(`Data Source Name: ${indexer.dataSourceName}`); - console.log(`Skillset Name: ${indexer.skillsetName}`); - console.log(`Target Index Name: ${indexer.targetIndexName}`); - console.log(`Is Disabled: ${indexer.isDisabled}`); - console.log(`ETag: ${indexer.etag}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/getIndexerStatus.js b/sdk/search/search-documents/samples/javascript/src/indexers/getIndexerStatus.js deleted file mode 100644 index e279a2ee22f..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/getIndexerStatus.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Indexer Status Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer Status of my-azure-indexer-1`); - const indexerStatus = await client.getIndexerStatus("my-azure-indexer-1"); - console.log(`Status: ${indexerStatus.status}`); - console.log(`Limits`); - console.log(`******`); - console.log(`MaxDocumentContentCharactersToExtract: ${indexerStatus.limits.maxDocumentContentCharactersToExtract}`) - console.log(`MaxDocumentExtractionSize: ${indexerStatus.limits.maxDocumentExtractionSize}`) - console.log(`MaxRunTime: ${indexerStatus.limits.maxRunTime}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/listIndexerNames.js b/sdk/search/search-documents/samples/javascript/src/indexers/listIndexerNames.js deleted file mode 100644 index 3f0f6765e40..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/listIndexerNames.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Indexer Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfIndexerNames = await client.listIndexersNames(); - - console.log(`\tNames of Indexers`); - console.log(`\t*****************`); - for(const indexerName of listOfIndexerNames) { - console.log(`${indexerName}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/listIndexers.js b/sdk/search/search-documents/samples/javascript/src/indexers/listIndexers.js deleted file mode 100644 index f59cbce26e9..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/listIndexers.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Indexers Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfIndexers = await client.listIndexers(); - - console.log(`\tList of Indexers`); - console.log(`\t****************`); - for(const indexer of listOfIndexers) { - console.log(`Name: ${indexer.name}`); - console.log(`Description: ${indexer.description}`); - console.log(`Data Source Name: ${indexer.dataSourceName}`); - console.log(`Skillset Name: ${indexer.skillsetName}`); - console.log(`Target Index Name: ${indexer.targetIndexName}`); - console.log(`Is Disabled: ${indexer.isDisabled}`); - console.log(`ETag: ${indexer.etag}`); - console.log(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/resetIndexer.js b/sdk/search/search-documents/samples/javascript/src/indexers/resetIndexer.js deleted file mode 100644 index 63bdeded5dc..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/resetIndexer.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Reset Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Reset Indexer my-azure-indexer-1`); - await client.resetIndexer("my-azure-indexer-1"); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexers/runIndexer.js b/sdk/search/search-documents/samples/javascript/src/indexers/runIndexer.js deleted file mode 100644 index 780d0e9a64c..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexers/runIndexer.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Run Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Run Indexer my-azure-indexer-1`); - await client.runIndexer("my-azure-indexer-1"); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/analyzeText.js b/sdk/search/search-documents/samples/javascript/src/indexes/analyzeText.js deleted file mode 100644 index a131b99f65e..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/analyzeText.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -/* eslint-disable no-unused-expressions */ - -const { - SearchIndexClient, - AzureKeyCredential, - KnownTokenFilterNames -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Analyze Text Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const index = await client.getIndex("example-index"); - - // Note adding this analyzer to an existing index will cause it to be unresponsive - // for a short period, hence the need to pass `allowIndexDowntime: true`. - await client.createOrUpdateIndex(index, { allowIndexDowntime: true }); - - const result = await client.analyzeText("example-index", { - text: "MSFT is xyzzy Great!", - analyzerName: "example-analyzer" - }); - - console.log(result.tokens); - -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/createIndex.js b/sdk/search/search-documents/samples/javascript/src/indexes/createIndex.js deleted file mode 100644 index e3251b1d029..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/createIndex.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const index = { - name: "example-index-2", - fields: [ - { - type: "Edm.String", - name: "id", - key: true - }, - { - type: "Edm.Double", - name: "awesomenessLevel", - sortable: true, - filterable: true, - facetable: true - }, - { - type: "Edm.String", - name: "description", - searchable: true - }, - { - type: "Edm.ComplexType", - name: "details", - fields: [ - { - type: "Collection(Edm.String)", - name: "tags", - searchable: true - } - ] - }, - { - type: "Edm.Int32", - name: "hiddenWeight", - hidden: true - } - ] - }; - await client.createIndex(index); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/createOrUpdateIndex.js b/sdk/search/search-documents/samples/javascript/src/indexes/createOrUpdateIndex.js deleted file mode 100644 index 974f160cd4a..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/createOrUpdateIndex.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Or Update Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index example-index-2`); - const index = await client.getIndex("example-index-2"); - console.log(`Adding fields to Index example-index-2`); - index.fields.push({ - type: "Edm.DateTimeOffset", - name: "lastUpdatedOn", - filterable: true - }); - - - await client.createOrUpdateIndex(index); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByName.js b/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByName.js deleted file mode 100644 index 6a6e6fce116..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByName.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Index example-index-2`); - await client.deleteIndex("example-index-2") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByObject.js b/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByObject.js deleted file mode 100644 index 83b88b1384f..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/deleteIndexByObject.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index example-index-2`); - const index = await client.getIndex("example-index-2"); - console.log(`Deleting Index example-index-2`); - await client.deleteIndex(index); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/getIndex.js b/sdk/search/search-documents/samples/javascript/src/indexes/getIndex.js deleted file mode 100644 index 3fffaeb1d67..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/getIndex.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index example-index`); - const index = await client.getIndex("example-index"); - console.log(`Name: ${index.name}`); - console.log(`Similarity Algorithm: ${index.similarity.odatatype}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/getIndexStatistics.js b/sdk/search/search-documents/samples/javascript/src/indexes/getIndexStatistics.js deleted file mode 100644 index 4a937b669c4..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/getIndexStatistics.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Index Statistics Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index Statistics of example-index`); - const statistics = await client.getIndexStatistics("example-index"); - console.log(`Document Count: ${statistics.documentCount}`); - console.log(`Storage Size: ${statistics.storageSize}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/getServiceStatistics.js b/sdk/search/search-documents/samples/javascript/src/indexes/getServiceStatistics.js deleted file mode 100644 index bf4ec00363a..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/getServiceStatistics.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Service Statistics Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const {counters, limits} = await client.getServiceStatistics(); - console.log(`Counters`); - console.log(`========`); - console.log(`\tDocument Counter`); - console.log(`\t\tUsage: ${counters.documentCounter.usage}`); - console.log(`\t\tQuota: ${counters.documentCounter.quota}`); - console.log(`\tIndex Counter`); - console.log(`\t\tUsage: ${counters.indexCounter.usage}`); - console.log(`\t\tQuota: ${counters.indexCounter.quota}`); - console.log(`\tIndexer Counter`); - console.log(`\t\tUsage: ${counters.indexerCounter.usage}`); - console.log(`\t\tQuota: ${counters.indexerCounter.quota}`); - console.log(`\tData Source Counter`); - console.log(`\t\tUsage: ${counters.dataSourceCounter.usage}`); - console.log(`\t\tQuota: ${counters.dataSourceCounter.quota}`); - console.log(`\tStorage Size Counter`); - console.log(`\t\tUsage: ${counters.storageSizeCounter.usage}`); - console.log(`\t\tQuota: ${counters.storageSizeCounter.quota}`); - console.log(`\tSynonym Map Counter`); - console.log(`\t\tUsage: ${counters.synonymMapCounter.usage}`); - console.log(`\t\tQuota: ${counters.synonymMapCounter.quota}`); - console.log(); - console.log(`Limits`); - console.log(`======`); - console.log(`\tMax Fields Per Index: ${limits.maxFieldsPerIndex}`); - console.log(`\tMax Field Nesting Depth Per Index: ${limits.maxFieldNestingDepthPerIndex}`); - console.log(`\tMax Complex Collection Fields Per Index: ${limits.maxComplexCollectionFieldsPerIndex}`); - console.log(`\tMax Complex Objects In Collections Per Document: ${limits.maxComplexObjectsInCollectionsPerDocument}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/listIndexNames.js b/sdk/search/search-documents/samples/javascript/src/indexes/listIndexNames.js deleted file mode 100644 index db2f516fe30..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/listIndexNames.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Indexes Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const result = await client.listIndexesNames(); - let listOfIndexNames = await result.next(); - - console.log(`List of Index Names`); - console.log(`*******************`); - while (!listOfIndexNames.done) { - console.log(listOfIndexNames.value); - listOfIndexNames = await result.next(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/indexes/listIndexes.js b/sdk/search/search-documents/samples/javascript/src/indexes/listIndexes.js deleted file mode 100644 index 3647f27b80d..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/indexes/listIndexes.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Indexes Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const result = await client.listIndexes(); - let listOfIndexes = await result.next(); - - console.log(`List of Indexes`); - console.log(`***************`); - while (!listOfIndexes.done) { - console.log(`Name: ${listOfIndexes.value.name}`); - console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity.odatatype}`); - console.log(); - listOfIndexes = await result.next(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/createOrUpdateSkillset.js b/sdk/search/search-documents/samples/javascript/src/skillSets/createOrUpdateSkillset.js deleted file mode 100644 index d2b6a98601f..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/createOrUpdateSkillset.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Or Update Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Skillset my-azureblob-skillset`); - const skillset = await client.getSkillset("my-azureblob-skillset"); - - skillset.skills[0].outputs = [ - { - name: "persons", - targetName: "people" - }, - { - name: "organizations", - targetName: "organizations" - } - ] - - await client.createOrUpdateSkillset(skillset); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/createSkillset.js b/sdk/search/search-documents/samples/javascript/src/skillSets/createSkillset.js deleted file mode 100644 index 687c5e39f19..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/createSkillset.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const skillset = { - name: `my-azureblob-skillset`, - description: `Skillset description`, - skills: [ - { - odatatype: "#Microsoft.Skills.Text.EntityRecognitionSkill", - inputs: [ - { - name: "text", - source: "/document/merged_content" - }, - { - name: "languageCode", - source: "/document/language" - } - ], - outputs: [ - { - name: "persons", - targetName: "people" - }, - { - name: "organizations", - targetName: "organizations" - }, - { - name: "locations", - targetName: "locations" - } - ] - } - ] - }; - await client.createSkillset(skillset); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByName.js b/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByName.js deleted file mode 100644 index 0fac0de3790..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByName.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Indexer my-azureblob-skillset`); - await client.deleteSkillset("my-azureblob-skillset") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByObject.js b/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByObject.js deleted file mode 100644 index 936493eaec8..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/deleteSkillsetByObject.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Skillset my-azureblob-skillset`); - const skillset = await client.getSkillset("my-azureblob-skillset"); - console.log(`Deleting Indexer my-azureblob-skillset`); - await client.deleteSkillset(skillset) -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/getSkillset.js b/sdk/search/search-documents/samples/javascript/src/skillSets/getSkillset.js deleted file mode 100644 index 0ee2d26cb26..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/getSkillset.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Skillset my-azureblob-skillset`); - const skillset = await client.getSkillset("my-azureblob-skillset"); - console.log(`Name: ${skillset.name}`); - console.log(`Description: ${skillset.description}`); - console.log(`Skills`); - console.log(`******`); - for(const skill of skillset.skills) { - console.log(`ODataType: ${skill.odatatype}`); - console.log(`Inputs`); - for(const input of skill.inputs) { - console.log(`\tName: ${input.name}`); - console.log(`\tSource: ${input.source}`); - } - console.log(`Outputs`); - for(const output of skill.outputs) { - console.log(`\tName: ${output.name}`); - console.log(`\tTarget Name: ${output.targetName}`); - } - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsets.js b/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsets.js deleted file mode 100644 index fde6cced256..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsets.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexerClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Skillsets Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSkillsets = await client.listSkillsets(); - - console.log(`\tList of Skillsets`); - console.log(`\t******************`); - for(const skillset of listOfSkillsets) { - console.log(`Name: ${skillset.name}`); - console.log(`Description: ${skillset.description}`); - console.log(`Skills`); - console.log(`******`); - for(const skill of skillset.skills) { - console.log(`ODataType: ${skill.odatatype}`); - console.log(`Inputs`); - for(const input of skill.inputs) { - console.log(`\tName: ${input.name}`); - console.log(`\tSource: ${input.source}`); - } - console.log(`Outputs`); - for(const output of skill.outputs) { - console.log(`\tName: ${output.name}`); - console.log(`\tTarget Name: ${output.targetName}`); - } - } - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsetsNames.js b/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsetsNames.js deleted file mode 100644 index db7ac177586..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/skillSets/listSkillsetsNames.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List Skillsets Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSkillsetNames = await client.listSkillsetsNames(); - - console.log(`\tNames of Skillsets`); - console.log(`\t******************`); - for(const skName of listOfSkillsetNames) { - console.log(`${skName}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/createOrUpdateSynonymMap.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/createOrUpdateSynonymMap.js deleted file mode 100644 index aefc81597f3..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/createOrUpdateSynonymMap.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create Or Update SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Synonym Map my-synonymmap`); - const sm = await client.getSynonymMap("my-synonymmap"); - console.log(`Update synonyms Synonym Map my-synonymmap`); - sm.synonyms.push("Florida, Fld. => FL"); - await client.createOrUpdateSynonymMap(sm); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/createSynonymMap.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/createSynonymMap.js deleted file mode 100644 index 5ae44fb8ac3..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/createSynonymMap.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Create SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const sm = { - name: `my-synonymmap`, - synonyms: ["United States, United States of America => USA", "Washington, Wash. => WA"] - }; - await client.createSynonymMap(sm); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByName.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByName.js deleted file mode 100644 index a5afa82a924..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByName.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting SynonymMap my-synonymmap`); - await client.deleteSynonymMap("my-synonymmap") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByObject.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByObject.js deleted file mode 100644 index 267eda8294a..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/deleteSynonymMapByObject.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Delete SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Synonym Map my-synonymmap`); - const sm = await client.getSynonymMap("my-synonymmap"); - console.log(`Deleting SynonymMap my-synonymmap`); - await client.deleteSynonymMap(sm); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/getSynonymMap.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/getSynonymMap.js deleted file mode 100644 index 55ca8cee3b1..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/getSynonymMap.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { - SearchIndexClient, - AzureKeyCredential -} = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running Get SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Synonym Map my-synonymmap`); - const sm = await client.getSynonymMap("my-synonymmap"); - console.log(`Name: ${sm.name}`); - console.log(`Synonyms`); - for(const synonym of sm.synonyms) { - console.log(synonym); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMapNames.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMapNames.js deleted file mode 100644 index aea41900f3b..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMapNames.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List SynonymMap Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSynonymMapsNames = await client.listSynonymMapsNames(); - - console.log(`List of SynonymMap Names`); - console.log(`************************`); - for(const smName of listOfSynonymMapsNames) { - console.log(`${smName}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMaps.js b/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMaps.js deleted file mode 100644 index 6b084f12570..00000000000 --- a/sdk/search/search-documents/samples/javascript/src/synonymMaps/listSynonymMaps.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); -require("dotenv").config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -async function main() { - console.log(`Running List SynonymMaps Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSynonymMaps = await client.listSynonymMaps(); - - console.log(`List of SynonymMaps`); - console.log(`*******************`); - for(const sm of listOfSynonymMaps) { - console.log(`Name: ${sm.name}`); - console.log(`Synonyms`); - for(const synonym of sm.synonyms) { - console.log(synonym); - } - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/tsconfig.json b/sdk/search/search-documents/samples/tsconfig.json deleted file mode 100644 index e2189ec9b45..00000000000 --- a/sdk/search/search-documents/samples/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "typescript/dist", - "lib": ["DOM", "ES6"] - }, - "include": ["typescript/src/**.ts", "typescript/src/**/**.ts"], - "exclude": ["typescript/*.json", "**/node_modules/", "../node_modules", "../typings"] -} diff --git a/sdk/search/search-documents/samples/typescript/README.md b/sdk/search/search-documents/samples/typescript/README.md deleted file mode 100644 index b8a34f4e53e..00000000000 --- a/sdk/search/search-documents/samples/typescript/README.md +++ /dev/null @@ -1,146 +0,0 @@ -# Azure Cognitive Search client library samples for TypeScript - -These sample programs show how to use the TypeScript client libraries for Azure Cognitive Search in some common scenarios. - -| **File Name** | **Description** | -| ---------------------------- | ------------------------ | -| **Data Source Connections** | -| [createDataSourceConnection.ts][createDataSourceConnection] | Creates a Datasource Connection | -| [createOrUpdateDataSourceConnection.ts][createOrUpdateDataSourceConnection] | Updates a Datasource Connection | -| [deleteDataSourceConnectionByName.ts][deleteDataSourceConnectionByName] | Deletes Datasource Connection by Name | -| [deleteDataSourceConnectionByObject.ts][deleteDataSourceConnectionByObject] | Deletes Datasource Connection by Object | -| [getDataSourceConnection.ts][getDataSourceConnection] | Gets a Datasource Connection | -| [listDataSourceConnectionNames.ts][listDataSourceConnectionNames] | List names of Datasource Connections | -| [listDataSourceConnections.ts][listDataSourceConnections] | List Datasource Connections | -| **Indexers** | -| [createIndexer.ts][createIndexer] | Creates an Indexer | -| [createOrUpdateIndexer.ts][createOrUpdateIndexer] | Updates an Indexer | -| [deleteIndexerByName.ts][deleteIndexerByName] | Deletes Indexer by Name | -| [deleteIndexerByObject.ts][deleteIndexerByObject] | Deletes Indexer by Object | -| [getIndexer.ts][getIndexer] | Gets an Indexer | -| [getIndexerStatus.ts][getIndexerStatus] | Gets the status of an Indexer | -| [listIndexerNames.ts][listIndexerNames] | List names of Indexers | -| [listIndexers.ts][listIndexers] | List Indexers | -| [resetIndexer.ts][resetIndexer] | Resets an Indexer | -| [runIndexer.ts][runIndexer] | Runs an Indexer | -| **Indexes** | -| [analyzeText.ts][analyzeText] | Analyzes a given text | -| [createIndex.ts][createIndex] | Creates an Index | -| [createOrUpdateIndex.ts][createOrUpdateIndex] | Updates an Index | -| [deleteIndexByName.ts][deleteIndexByName] | Deletes Index by Name | -| [deleteIndexByObject.ts][deleteIndexByObject] | Deletes Index by Object | -| [getIndex.ts][getIndex] | Gets an Index | -| [getIndexStatistics.ts][getIndexStatistics] | Gets the Statistics of an Index | -| [listIndexes.ts][listIndexes] | List Indexes | -| [listIndexNames.ts][listIndexNames] | List Names of Indexes | -| **Skillsets** | -| [createOrUpdateSkillset.ts][createOrUpdateSkillset] | Updates a skillset | -| [createSkillset.ts][createSkillset] | Creates a skillset | -| [deleteSkillsetByName.ts][deleteSkillsetByName] | Deletes a Skillset by Name | -| [deleteSkillsetByObject.ts][deleteSkillsetByObject] | Deletes a Skillset by Object | -| [getSkillset.ts][getSkillset] | Gets a skillset | -| [listSkillsets.ts][listSkillsets] | List all skillsets | -| [listSkillsetsNames.ts][listSkillsetsNames] | List names of skillsets | -| **SynonymMaps** | -| [createOrUpdateSynonymMap.ts][createOrUpdateSynonymMap] | Updates a synonym map | -| [createSynonymMap.ts][createSynonymMap] | Creates a synonym map | -| [deleteSynonymMapByName.ts][deleteSynonymMapByName] | Deletes a synonym map by Name | -| [deleteSynonymMapByObject.ts][deleteSynonymMapByObject] | Deletes a synonym map by object | -| [getSynonymMap.ts][getSynonymMap] | Gets a synonym map | -| [listSynonymMapNames.ts][listSynonymMapNames] | List names of synonym maps | -| [listSynonymMaps.ts][listSynonymMaps] | List all synonym maps | - -## Prerequisites - -The samples are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). - -Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using - -```bash -npm install -g typescript -``` - -You need [an Azure subscription][freesub] and [an Azure Cognitive Search service][search_resource] to run these sample programs. Samples retrieve credentials to access the Azure Cognitive Search endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Compile the samples - -```bash -npm run build -``` - -3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -4. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node dist/readonlyQuery.js -``` - -Alternatively, run a single sample with the correct environment variables set (step 3 is not required if you do this), for example (cross-platform): - -```bash -npx cross-env SEARCH_API_ENDPOINT="" SEARCH_API_KEY="" node dist/readonlyQuery.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[readonly]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/readonlyQuery.ts -[apiref]: https://aka.ms/azsdk/js/search/docs -[search_resource]: https://docs.microsoft.com/azure/search/search-create-service-portal -[freesub]: https://azure.microsoft.com/free/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/README.md -[typescript]: https://www.typescriptlang.org/docs/home.html -[createDataSourceConnection]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createDataSourceConnection.ts -[createOrUpdateDataSourceConnection]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createOrUpdateDataSourceConnection.ts -[deleteDataSourceConnectionByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByName.ts -[deleteDataSourceConnectionByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByObject.ts -[getDataSourceConnection]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/getDataSourceConnection.ts -[listDataSourceConnectionNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnectionNames.ts -[listDataSourceConnections]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnections.ts -[createIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/createIndexer.ts -[createOrUpdateIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/createOrUpdateIndexer.ts -[deleteIndexerByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByName.ts -[deleteIndexerByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByObject.ts -[getIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/getIndexer.ts -[getIndexerStatus]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/getIndexerStatus.ts -[listIndexerNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/listIndexerNames.ts -[listIndexers]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/listIndexers.ts -[resetIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/resetIndexer.ts -[runIndexer]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexers/runIndexer.ts -[analyzeText]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/analyzeText.ts -[createIndex]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/createIndex.ts -[createOrUpdateIndex]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/createOrUpdateIndex.ts -[deleteIndexByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByName.ts -[deleteIndexByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByObject.ts -[getIndex]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/getIndex.ts -[getIndexStatistics]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/getIndexStatistics.ts -[listIndexes]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/listIndexes.ts -[listIndexNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/indexes/listIndexNames.ts -[createOrUpdateSkillset]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/createOrUpdateSkillset.ts -[createSkillset]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/createSkillset.ts -[deleteSkillsetByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByName.ts -[deleteSkillsetByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByObject.ts -[getSkillset]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/getSkillset.ts -[listSkillsets]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsets.ts -[listSkillsetsNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsetsNames.ts -[createOrUpdateSynonymMap]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/createOrUpdateSynonymMap.ts -[createSynonymMap]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/createSynonymMap.ts -[deleteSynonymMapByName]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByName.ts -[deleteSynonymMapByObject]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByObject.ts -[getSynonymMap]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/getSynonymMap.ts -[listSynonymMapNames]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMapNames.ts -[listSynonymMaps]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMaps.ts diff --git a/sdk/search/search-documents/samples/typescript/sample.env b/sdk/search/search-documents/samples/typescript/sample.env deleted file mode 100644 index 2cc6850cb8f..00000000000 --- a/sdk/search/search-documents/samples/typescript/sample.env +++ /dev/null @@ -1,6 +0,0 @@ -# Used in most samples. Retrieve these values from a Cognitive Services instance -# in the Azure Portal. - -SEARCH_API_KEY= -SEARCH_API_ENDPOINT=https://.search.windows.net -INDEX_NAME=hotels-sample-index diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createDataSourceConnection.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createDataSourceConnection.ts deleted file mode 100644 index 79b08978fa7..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createDataSourceConnection.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerDataSourceConnection -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const dataSourceConnection: SearchIndexerDataSourceConnection = { - name: "my-data-source-2", - description: "My Data Source 1", - type: "cosmosdb", - container: { - name: "my-container-1" - }, - connectionString: - "AccountEndpoint=https://hotels-docbb.documents.azure.com:443/;AccountKey=4UPsNZyFAjgZ1tzHPGZaxS09XcwLrIawbXBWk6IixcxJoSePTcjBn0mi53XiKWu8MaUgowUhIovOv7kjksqAug==;Database=SampleData" - }; - await client.createDataSourceConnection(dataSourceConnection); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createOrUpdateDataSourceConnection.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createOrUpdateDataSourceConnection.ts deleted file mode 100644 index 6a97120f4ae..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/createOrUpdateDataSourceConnection.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerDataSourceConnection -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running CreateOrUpdate Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Datasource Connection my-data-source-2`); - const ds:SearchIndexerDataSourceConnection = await client.getDataSourceConnection("my-data-source-2") - ds.container.name = "Listings_5K_KingCounty_WA"; - console.log(`Updating Container Name of Datasource Connection my-data-source-2`); - await client.createOrUpdateDataSourceConnection(ds); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByName.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByName.ts deleted file mode 100644 index 330184809ab..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByName.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Datasource Connection my-data-source-2`); - await client.deleteDataSourceConnection("my-data-source-2") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByObject.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByObject.ts deleted file mode 100644 index 62abedf952c..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/deleteDataSourceConnectionByObject.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerDataSourceConnection -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Datasource Connection my-data-source-2`); - const ds:SearchIndexerDataSourceConnection = await client.getDataSourceConnection("my-data-source-2"); - console.log(`Deleting Datasource Connection my-data-source-2`); - await client.deleteDataSourceConnection(ds); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/getDataSourceConnection.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/getDataSourceConnection.ts deleted file mode 100644 index 71e6edaf246..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/getDataSourceConnection.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerDataSourceConnection -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Datasource Connection Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Datasource Connection my-data-source-2`); - const ds:SearchIndexerDataSourceConnection = await client.getDataSourceConnection("my-data-source-2") - console.log(`Name: ${ds.name}`); - console.log(`Description: ${ds.description}`); - console.log(`Connection String: ${ds.connectionString}`); - console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); - console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); - console.log(`Etag: ${ds.etag}`); - console.log(`DataContainer`); - console.log(`\tName: ${ds.container.name}`); - console.log(`\tQuery: ${ds.container.query}`); - console.log(); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnectionNames.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnectionNames.ts deleted file mode 100644 index 47dd60710b4..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnectionNames.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Datasource Connection Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfDataSourceConnectionNames: string[] = await client.listDataSourceConnectionsNames(); - - console.log(`Names of Data Source Connections`); - console.log(`*******************************`); - for (let ds of listOfDataSourceConnectionNames) { - console.log(ds); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnections.ts b/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnections.ts deleted file mode 100644 index cccd4ac471c..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/dataSourceConnections/listDataSourceConnections.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerDataSourceConnection -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Datasource Connections Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfDataSourceConnections: Array = await client.listDataSourceConnections(); - - console.log(`List of Data Source Connections`); - console.log(`*******************************`); - for (let ds of listOfDataSourceConnections) { - console.log(`Name: ${ds.name}`); - console.log(`Description: ${ds.description}`); - console.log(`Connection String: ${ds.connectionString}`); - console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); - console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); - console.log(`Etag: ${ds.etag}`); - console.log(`DataContainer`); - console.log(`\tName: ${ds.container.name}`); - console.log(`\tQuery: ${ds.container.query}`); - console.log(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/createIndexer.ts b/sdk/search/search-documents/samples/typescript/src/indexers/createIndexer.ts deleted file mode 100644 index b7259f6c312..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/createIndexer.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexer } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const indexer: SearchIndexer = { - name: "my-azure-indexer-1", - description: "Description for Sample Indexer", - dataSourceName: "realestate-us-sample", - targetIndexName: "realestate-us-sample-index", - isDisabled: false - }; - - await client.createIndexer(indexer); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/createOrUpdateIndexer.ts b/sdk/search/search-documents/samples/typescript/src/indexers/createOrUpdateIndexer.ts deleted file mode 100644 index bab817ad18e..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/createOrUpdateIndexer.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexer } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Or Update Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer my-azure-indexer-1`); - const indexer: SearchIndexer = await client.getIndexer("my-azure-indexer-1"); - console.log(`Updating isDisabled status of Indexer my-azure-indexer-1`); - indexer.isDisabled = true; - await client.createOrUpdateIndexer(indexer); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByName.ts b/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByName.ts deleted file mode 100644 index 8077d6a75f6..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByName.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Indexer my-azure-indexer-1`); - await client.deleteIndexer("my-azure-indexer-1") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByObject.ts b/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByObject.ts deleted file mode 100644 index 71d7817282f..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/deleteIndexerByObject.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexer -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer my-azure-indexer-1`); - const indexer: SearchIndexer = await client.getIndexer("my-azure-indexer-1"); - console.log(`Deleting Indexer my-azure-indexer-1`); - await client.deleteIndexer(indexer); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/getIndexer.ts b/sdk/search/search-documents/samples/typescript/src/indexers/getIndexer.ts deleted file mode 100644 index 85cfa53770a..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/getIndexer.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexer } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer my-azure-indexer-1`); - const indexer: SearchIndexer = await client.getIndexer("my-azure-indexer-1"); - console.log(`Name: ${indexer.name}`); - console.log(`Description: ${indexer.description}`); - console.log(`Data Source Name: ${indexer.dataSourceName}`); - console.log(`Skillset Name: ${indexer.skillsetName}`); - console.log(`Target Index Name: ${indexer.targetIndexName}`); - console.log(`Indexing Schedule`); - console.log(`\tInterval: ${indexer.schedule?.interval}`); - console.log(`\tStart Time: ${indexer.schedule?.startTime}`); - console.log(`Is Disabled: ${indexer.isDisabled}`); - console.log(`ETag: ${indexer.etag}`); - console.log(`Parameters`); - console.log(`\tBatch Size: ${indexer.parameters?.batchSize}`); - console.log(`\tMax Failed Items: ${indexer.parameters?.maxFailedItems}`); - console.log(`\tMax Failed Items Per Batch: ${indexer.parameters?.maxFailedItemsPerBatch}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/getIndexerStatus.ts b/sdk/search/search-documents/samples/typescript/src/indexers/getIndexerStatus.ts deleted file mode 100644 index 15a11b1a2db..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/getIndexerStatus.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexerStatus } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Indexer Status Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Indexer Status of my-azure-indexer-1`); - const indexerStatus: SearchIndexerStatus = await client.getIndexerStatus("my-azure-indexer-1"); - console.log(`Status: ${indexerStatus.status}`); - console.log(`Limits`); - console.log(`******`); - console.log(`MaxDocumentContentCharactersToExtract: ${indexerStatus.limits.maxDocumentContentCharactersToExtract}`) - console.log(`MaxDocumentExtractionSize: ${indexerStatus.limits.maxDocumentExtractionSize}`) - console.log(`MaxRunTime: ${indexerStatus.limits.maxRunTime}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/listIndexerNames.ts b/sdk/search/search-documents/samples/typescript/src/indexers/listIndexerNames.ts deleted file mode 100644 index ac8edd85d4c..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/listIndexerNames.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Indexer Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfIndexerNames: string[] = await client.listIndexersNames(); - - console.log(`\tNames of Indexers`); - console.log(`\t*****************`); - for (let indexerName of listOfIndexerNames) { - console.log(`${indexerName}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/listIndexers.ts b/sdk/search/search-documents/samples/typescript/src/indexers/listIndexers.ts deleted file mode 100644 index d1fa14d55de..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/listIndexers.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexer } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Indexers Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfIndexers: Array = await client.listIndexers(); - - console.log(`\tList of Indexers`); - console.log(`\t****************`); - for (let indexer of listOfIndexers) { - console.log(`Name: ${indexer.name}`); - console.log(`Description: ${indexer.description}`); - console.log(`Data Source Name: ${indexer.dataSourceName}`); - console.log(`Skillset Name: ${indexer.skillsetName}`); - console.log(`Target Index Name: ${indexer.targetIndexName}`); - console.log(`Indexing Schedule`); - console.log(`\tInterval: ${indexer.schedule?.interval}`); - console.log(`\tStart Time: ${indexer.schedule?.startTime}`); - console.log(`Is Disabled: ${indexer.isDisabled}`); - console.log(`ETag: ${indexer.etag}`); - console.log(`Parameters`); - console.log(`\tBatch Size: ${indexer.parameters?.batchSize}`); - console.log(`\tMax Failed Items: ${indexer.parameters?.maxFailedItems}`); - console.log(`\tMax Failed Items Per Batch: ${indexer.parameters?.maxFailedItemsPerBatch}`); - console.log(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/resetIndexer.ts b/sdk/search/search-documents/samples/typescript/src/indexers/resetIndexer.ts deleted file mode 100644 index 97d80777608..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/resetIndexer.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Reset Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Reset Indexer my-azure-indexer-1`); - await client.resetIndexer("my-azure-indexer-1"); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexers/runIndexer.ts b/sdk/search/search-documents/samples/typescript/src/indexers/runIndexer.ts deleted file mode 100644 index a839f74ecfd..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexers/runIndexer.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Run Indexer Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Run Indexer my-azure-indexer-1`); - await client.runIndexer("my-azure-indexer-1"); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/analyzeText.ts b/sdk/search/search-documents/samples/typescript/src/indexes/analyzeText.ts deleted file mode 100644 index 4eddc9ace75..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/analyzeText.ts +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -/* eslint-disable no-unused-expressions */ - -import { - SearchIndexClient, - AzureKeyCredential, - SearchIndex, - KnownTokenFilterNames -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Analyze Text Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const index: SearchIndex = await client.getIndex("example-index"); - - index.tokenizers?.push({ - name: "example-tokenizer", - odatatype: "#Microsoft.Azure.Search.StandardTokenizerV2", - maxTokenLength: 125 - }); - - index.charFilters?.push({ - name: "example-char-filter", - odatatype: "#Microsoft.Azure.Search.MappingCharFilter", - mappings: ["MSFT=>Microsoft"] - }); - - index.tokenFilters?.push({ - name: "example-token-filter", - odatatype: "#Microsoft.Azure.Search.StopwordsTokenFilter", - stopwords: ["xyzzy"] - }); - - index.analyzers?.push({ - name: "example-analyzer", - odatatype: "#Microsoft.Azure.Search.CustomAnalyzer", - tokenizerName: "example-tokenizer", - charFilters: ["example-char-filter"], - tokenFilters: [KnownTokenFilterNames.Lowercase, "example-token-filter"] - }); - - // Note adding this analyzer to an existing index will cause it to be unresponsive - // for a short period, hence the need to pass `allowIndexDowntime: true`. - await client.createOrUpdateIndex(index, { allowIndexDowntime: true }); - - const result = await client.analyzeText("example-index", { - text: "MSFT is xyzzy Great!", - analyzerName: "example-analyzer" - }); - - console.log(result.tokens); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/createIndex.ts b/sdk/search/search-documents/samples/typescript/src/indexes/createIndex.ts deleted file mode 100644 index 71fc6462d77..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/createIndex.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SearchIndex -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const index: SearchIndex = { - name: "example-index-2", - fields: [ - { - type: "Edm.String", - name: "id", - key: true - }, - { - type: "Edm.Double", - name: "awesomenessLevel", - sortable: true, - filterable: true, - facetable: true - }, - { - type: "Edm.String", - name: "description", - searchable: true - }, - { - type: "Edm.ComplexType", - name: "details", - fields: [ - { - type: "Collection(Edm.String)", - name: "tags", - searchable: true - } - ] - }, - { - type: "Edm.Int32", - name: "hiddenWeight", - hidden: true - } - ] - }; - await client.createIndex(index); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/createOrUpdateIndex.ts b/sdk/search/search-documents/samples/typescript/src/indexes/createOrUpdateIndex.ts deleted file mode 100644 index 9593e718e31..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/createOrUpdateIndex.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SearchIndex -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Or Update Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index example-index-2`); - const index:SearchIndex = await client.getIndex("example-index-2"); - console.log(`Adding fields to Index example-index-2`); - index.fields.push({ - type: "Edm.DateTimeOffset", - name: "lastUpdatedOn", - filterable: true - }); - - - await client.createOrUpdateIndex(index); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByName.ts b/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByName.ts deleted file mode 100644 index 35311b14b9d..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByName.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Index example-index-2`); - await client.deleteIndex("example-index-2") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByObject.ts b/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByObject.ts deleted file mode 100644 index 180725060b3..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/deleteIndexByObject.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SearchIndex -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index example-index-2`); - const index:SearchIndex = await client.getIndex("example-index-2"); - console.log(`Deleting Index example-index-2`); - await client.deleteIndex(index); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/getIndex.ts b/sdk/search/search-documents/samples/typescript/src/indexes/getIndex.ts deleted file mode 100644 index 3fca09179e6..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/getIndex.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexClient, AzureKeyCredential, SearchIndex } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Index Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index example-index`); - const index: SearchIndex = await client.getIndex("example-index"); - console.log(`Name: ${index.name}`); - console.log(`Similarity Algorithm: ${index.similarity?.odatatype}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/getIndexStatistics.ts b/sdk/search/search-documents/samples/typescript/src/indexes/getIndexStatistics.ts deleted file mode 100644 index d964fde693a..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/getIndexStatistics.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SearchIndexStatistics -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Index Statistics Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Index Statistics of example-index`); - const statistics:SearchIndexStatistics = await client.getIndexStatistics("example-index"); - console.log(`Document Count: ${statistics.documentCount}`); - console.log(`Storage Size: ${statistics.storageSize}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/getServiceStatistics.ts b/sdk/search/search-documents/samples/typescript/src/indexes/getServiceStatistics.ts deleted file mode 100644 index 33be8e4df3c..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/getServiceStatistics.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Service Statistics Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const {counters, limits} = await client.getServiceStatistics(); - console.log(`Counters`); - console.log(`========`); - console.log(`\tDocument Counter`); - console.log(`\t\tUsage: ${counters.documentCounter.usage}`); - console.log(`\t\tQuota: ${counters.documentCounter.quota}`); - console.log(`\tIndex Counter`); - console.log(`\t\tUsage: ${counters.indexCounter.usage}`); - console.log(`\t\tQuota: ${counters.indexCounter.quota}`); - console.log(`\tIndexer Counter`); - console.log(`\t\tUsage: ${counters.indexerCounter.usage}`); - console.log(`\t\tQuota: ${counters.indexerCounter.quota}`); - console.log(`\tData Source Counter`); - console.log(`\t\tUsage: ${counters.dataSourceCounter.usage}`); - console.log(`\t\tQuota: ${counters.dataSourceCounter.quota}`); - console.log(`\tStorage Size Counter`); - console.log(`\t\tUsage: ${counters.storageSizeCounter.usage}`); - console.log(`\t\tQuota: ${counters.storageSizeCounter.quota}`); - console.log(`\tSynonym Map Counter`); - console.log(`\t\tUsage: ${counters.synonymMapCounter.usage}`); - console.log(`\t\tQuota: ${counters.synonymMapCounter.quota}`); - console.log(); - console.log(`Limits`); - console.log(`======`); - console.log(`\tMax Fields Per Index: ${limits.maxFieldsPerIndex}`); - console.log(`\tMax Field Nesting Depth Per Index: ${limits.maxFieldNestingDepthPerIndex}`); - console.log(`\tMax Complex Collection Fields Per Index: ${limits.maxComplexCollectionFieldsPerIndex}`); - console.log(`\tMax Complex Objects In Collections Per Document: ${limits.maxComplexObjectsInCollectionsPerDocument}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/listIndexNames.ts b/sdk/search/search-documents/samples/typescript/src/indexes/listIndexNames.ts deleted file mode 100644 index 4d91031be17..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/listIndexNames.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Indexes Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const result = await client.listIndexesNames(); - let listOfIndexNames = await result.next(); - - console.log(`List of Index Names`); - console.log(`*******************`); - while (!listOfIndexNames.done) { - console.log(listOfIndexNames.value); - listOfIndexNames = await result.next(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/indexes/listIndexes.ts b/sdk/search/search-documents/samples/typescript/src/indexes/listIndexes.ts deleted file mode 100644 index bebf901c9e2..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/indexes/listIndexes.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Indexes Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const result = await client.listIndexes(); - let listOfIndexes = await result.next(); - - console.log(`List of Indexes`); - console.log(`***************`); - while (!listOfIndexes.done) { - console.log(`Name: ${listOfIndexes.value.name}`); - console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); - console.log(); - listOfIndexes = await result.next(); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/createOrUpdateSkillset.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/createOrUpdateSkillset.ts deleted file mode 100644 index 5c8abaa5de5..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/createOrUpdateSkillset.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexerSkillset } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Or Update Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Skillset my-azureblob-skillset`); - const skillset: SearchIndexerSkillset = await client.getSkillset("my-azureblob-skillset"); - - skillset.skills[0].outputs = [ - { - name: "persons", - targetName: "people" - }, - { - name: "organizations", - targetName: "organizations" - } - ] - - await client.createOrUpdateSkillset(skillset); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/createSkillset.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/createSkillset.ts deleted file mode 100644 index c7915661c45..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/createSkillset.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential, SearchIndexerSkillset } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const skillset: SearchIndexerSkillset = { - name: `my-azureblob-skillset`, - description: `Skillset description`, - skills: [ - { - odatatype: "#Microsoft.Skills.Text.EntityRecognitionSkill", - inputs: [ - { - name: "text", - source: "/document/merged_content" - }, - { - name: "languageCode", - source: "/document/language" - } - ], - outputs: [ - { - name: "persons", - targetName: "people" - }, - { - name: "organizations", - targetName: "organizations" - }, - { - name: "locations", - targetName: "locations" - } - ] - } - ] - }; - await client.createSkillset(skillset); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByName.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByName.ts deleted file mode 100644 index 8862073d2aa..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByName.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting Indexer my-azureblob-skillset`); - await client.deleteSkillset("my-azureblob-skillset") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByObject.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByObject.ts deleted file mode 100644 index 59dd7daee68..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/deleteSkillsetByObject.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerSkillset -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Skillset my-azureblob-skillset`); - const skillset: SearchIndexerSkillset = await client.getSkillset("my-azureblob-skillset"); - console.log(`Deleting Indexer my-azureblob-skillset`); - await client.deleteSkillset(skillset) -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/getSkillset.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/getSkillset.ts deleted file mode 100644 index 7483338f8a1..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/getSkillset.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerSkillset -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get Skillset Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Getting Skillset my-azureblob-skillset`); - const skillset: SearchIndexerSkillset = await client.getSkillset("my-azureblob-skillset"); - console.log(`Name: ${skillset.name}`); - console.log(`Description: ${skillset.description}`); - console.log(`Skills`); - console.log(`******`); - for (let skill of skillset.skills) { - console.log(`ODataType: ${skill.odatatype}`); - console.log(`Inputs`); - for (let input of skill.inputs) { - console.log(`\tName: ${input.name}`); - console.log(`\tSource: ${input.source}`); - } - console.log(`Outputs`); - for (let output of skill.outputs) { - console.log(`\tName: ${output.name}`); - console.log(`\tTarget Name: ${output.targetName}`); - } - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsets.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsets.ts deleted file mode 100644 index c6a93418088..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsets.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexerClient, - AzureKeyCredential, - SearchIndexerSkillset -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Skillsets Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSkillsets: Array = await client.listSkillsets(); - - console.log(`\tList of Skillsets`); - console.log(`\t******************`); - for (let skillset of listOfSkillsets) { - console.log(`Name: ${skillset.name}`); - console.log(`Description: ${skillset.description}`); - console.log(`Skills`); - console.log(`******`); - for (let skill of skillset.skills) { - console.log(`ODataType: ${skill.odatatype}`); - console.log(`Inputs`); - for (let input of skill.inputs) { - console.log(`\tName: ${input.name}`); - console.log(`\tSource: ${input.source}`); - } - console.log(`Outputs`); - for (let output of skill.outputs) { - console.log(`\tName: ${output.name}`); - console.log(`\tTarget Name: ${output.targetName}`); - } - } - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsetsNames.ts b/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsetsNames.ts deleted file mode 100644 index 2e5e0fbd584..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/skillSets/listSkillsetsNames.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexerClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List Skillsets Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSkillsetNames: string[] = await client.listSkillsetsNames(); - - console.log(`\tNames of Skillsets`); - console.log(`\t******************`); - for (let skName of listOfSkillsetNames) { - console.log(`${skName}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/createOrUpdateSynonymMap.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/createOrUpdateSynonymMap.ts deleted file mode 100644 index 59482716b93..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/createOrUpdateSynonymMap.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SynonymMap -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create Or Update SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Synonym Map my-synonymmap`); - const sm:SynonymMap = await client.getSynonymMap("my-synonymmap"); - console.log(`Update synonyms Synonym Map my-synonymmap`); - sm.synonyms.push("Florida, Fld. => FL"); - await client.createOrUpdateSynonymMap(sm); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/createSynonymMap.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/createSynonymMap.ts deleted file mode 100644 index 2cf75fca98b..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/createSynonymMap.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SynonymMap -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Create SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const sm: SynonymMap = { - name: `my-synonymmap`, - synonyms: ["United States, United States of America => USA", "Washington, Wash. => WA"] - }; - await client.createSynonymMap(sm); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByName.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByName.ts deleted file mode 100644 index 27a17c3b201..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByName.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Deleting SynonymMap my-synonymmap`); - await client.deleteSynonymMap("my-synonymmap") -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByObject.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByObject.ts deleted file mode 100644 index e9f76704692..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/deleteSynonymMapByObject.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SynonymMap -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Delete SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Synonym Map my-synonymmap`); - const sm:SynonymMap = await client.getSynonymMap("my-synonymmap"); - console.log(`Deleting SynonymMap my-synonymmap`); - await client.deleteSynonymMap(sm); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/getSynonymMap.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/getSynonymMap.ts deleted file mode 100644 index 758691ac3ab..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/getSynonymMap.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SearchIndexClient, - AzureKeyCredential, - SynonymMap -} from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running Get SynonymMap Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - console.log(`Get Synonym Map my-synonymmap`); - const sm: SynonymMap = await client.getSynonymMap("my-synonymmap"); - console.log(`Name: ${sm.name}`); - console.log(`Synonyms`); - for (let synonym of sm.synonyms) { - console.log(synonym); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMapNames.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMapNames.ts deleted file mode 100644 index 91caa88363c..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMapNames.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexClient, AzureKeyCredential } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List SynonymMap Names Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSynonymMapsNames: string[] = await client.listSynonymMapsNames(); - - console.log(`List of SynonymMap Names`); - console.log(`************************`); - for (let smName of listOfSynonymMapsNames) { - console.log(`${smName}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMaps.ts b/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMaps.ts deleted file mode 100644 index 3afccce2309..00000000000 --- a/sdk/search/search-documents/samples/typescript/src/synonymMaps/listSynonymMaps.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents"; -import * as dotenv from "dotenv"; -dotenv.config(); - -const endpoint = process.env.SEARCH_API_ENDPOINT || ""; -const apiKey = process.env.SEARCH_API_KEY || ""; - -export async function main() { - console.log(`Running List SynonymMaps Sample....`); - if (!endpoint || !apiKey) { - console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); - return; - } - const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); - const listOfSynonymMaps: Array = await client.listSynonymMaps(); - - console.log(`List of SynonymMaps`); - console.log(`*******************`); - for (let sm of listOfSynonymMaps) { - console.log(`Name: ${sm.name}`); - console.log(`Synonyms`); - for (let synonym of sm.synonyms) { - console.log(synonym); - } - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/search/search-documents/samples/v11/javascript/README.md b/sdk/search/search-documents/samples/v11/javascript/README.md new file mode 100644 index 00000000000..7dbc3962788 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/README.md @@ -0,0 +1,82 @@ +--- +page_type: sample +languages: + - javascript +products: + - azure + - azure-cognitive-search + - azure-search +urlFragment: search-documents-javascript +--- + +# Azure Search Documents client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for Azure Search Documents in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| [bufferedSenderAutoFlushSize.js][bufferedsenderautoflushsize] | Demonstrates the SearchIndexingBufferedSender with Autoflush based on size. | +| [bufferedSenderAutoFlushTimer.js][bufferedsenderautoflushtimer] | Demonstrates the SearchIndexingBufferedSender with Autoflush based on timer. | +| [bufferedSenderManualFlush.js][bufferedsendermanualflush] | Demonstrates the SearchIndexingBufferedSender with Manual Flush. | +| [dataSourceConnectionOperations.js][datasourceconnectionoperations] | Demonstrates the DataSource Connection Operations. | +| [indexOperations.js][indexoperations] | Demonstrates the Index Operations. | +| [indexerOperations.js][indexeroperations] | Demonstrates the Indexer Operations. | +| [interfaces.js][interfaces] | Defines the Hotel Interface. | +| [setup.js][setup] | Defines the utility methods. | +| [skillSetOperations.js][skillsetoperations] | Demonstrates the Skillset Operations. | +| [synonymMapOperations.js][synonymmapoperations] | Demonstrates the SynonymMap Operations. | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: + +- [Azure Search Documents instance][createinstance_azuresearchdocumentsinstance] + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node bufferedSenderAutoFlushSize.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env ENDPOINT="" SEARCH_API_ADMIN_KEY="" node bufferedSenderAutoFlushSize.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[bufferedsenderautoflushsize]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js +[bufferedsenderautoflushtimer]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js +[bufferedsendermanualflush]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js +[datasourceconnectionoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js +[indexoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/indexOperations.js +[indexeroperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js +[interfaces]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/interfaces.js +[setup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/setup.js +[skillsetoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js +[synonymmapoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/search-documents +[freesub]: https://azure.microsoft.com/free/ +[createinstance_azuresearchdocumentsinstance]: https://docs.microsoft.com/azure/search/search-create-service-portal +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/README.md diff --git a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js new file mode 100644 index 00000000000..c6e377b2135 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Autoflush based on size. + */ + +const { + SearchIndexingBufferedSender, + AzureKeyCredential, + SearchClient, + GeographyPoint, + SearchIndexClient +} = require("@azure/search-documents"); +const { createIndex, documentKeyRetriever, WAIT_TIME } = require("./setup"); +const { delay } = require("@azure/core-http"); +const dotenv = require("dotenv"); +dotenv.config(); + +/** + * This sample is to demonstrate the use of SearchIndexingBufferedSender. + * In this sample, the autoFlush is set to true. i.e. the user does not + * want to call the flush manually. The upload action happen automatically + * when the size of the batch is greater than threshold (which is set to 1000) + * by default. + */ +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-4"; + +function getDocumentsArray(size) { + const array = []; + for (let i = 1; i <= size; i++) { + array.push({ + hotelId: `${i}`, + description: + "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, " + + "and a really helpful concierge. The location is perfect -- right downtown, close to all " + + "the tourist attractions. We highly recommend this hotel.", + descriptionFr: + "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine " + + "à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein " + + "centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement " + + "cet hôtel.", + hotelName: "Fancy Stay", + category: "Luxury", + tags: ["pool", "view", "wifi", "concierge"], + parkingIncluded: false, + lastRenovationDate: new Date(2010, 5, 27), + rating: 5, + location: new GeographyPoint({ + longitude: -122.131577, + latitude: 47.678581 + }) + }); + } + return array; +} + +async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-With Auto Flush Sizes Sample`); + + const credential = new AzureKeyCredential(apiKey); + const searchClient = new SearchClient(endpoint, TEST_INDEX_NAME, credential); + const indexClient = new SearchIndexClient(endpoint, credential); + + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + + const bufferedClient = new SearchIndexingBufferedSender(searchClient, documentKeyRetriever, { + autoFlush: true + }); + + bufferedClient.on("batchAdded", (response) => { + console.log(`Batch Added Event has been receieved: ${response}`); + }); + + bufferedClient.on("beforeDocumentSent", (response) => { + console.log(`Before Document Sent Event has been receieved: ${response}`); + }); + + bufferedClient.on("batchSucceeded", (response) => { + console.log("Batch Succeeded Event has been receieved...."); + console.log(response); + }); + + bufferedClient.on("batchFailed", (response) => { + console.log("Batch Failed Event has been receieved...."); + console.log(response); + }); + + const documents = getDocumentsArray(1001); + bufferedClient.uploadDocuments(documents); + + await WAIT_TIME; + + let count = await searchClient.getDocumentsCount(); + while (count !== documents.length) { + await delay(WAIT_TIME); + count = await searchClient.getDocumentsCount(); + } + + // When the autoFlush is set to true, the user + // has to call the dispose method to clear the + // timer. + bufferedClient.dispose(); + await indexClient.deleteIndex(TEST_INDEX_NAME); + await delay(WAIT_TIME); +} + +main(); diff --git a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js new file mode 100644 index 00000000000..9321cc884de --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Autoflush based on timer. + */ + +const { + SearchIndexingBufferedSender, + AzureKeyCredential, + SearchClient, + GeographyPoint, + SearchIndexClient, + DEFAULT_FLUSH_WINDOW +} = require("@azure/search-documents"); +const { createIndex, documentKeyRetriever, WAIT_TIME } = require("./setup"); +const { delay } = require("@azure/core-http"); +const dotenv = require("dotenv"); +dotenv.config(); + +/** + * This sample is to demonstrate the use of SearchIndexingBufferedSender. + * In this sample, the autoFlush is set to true. i.e. the user does not + * want to call the flush manually. The upload action happen automatically + * when the time interval is met. The time interval is set to 60000ms + * by default. + */ +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-5"; + +async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-With Auto Flush Timer Sample`); + + const credential = new AzureKeyCredential(apiKey); + const searchClient = new SearchClient(endpoint, TEST_INDEX_NAME, credential); + const indexClient = new SearchIndexClient(endpoint, credential); + + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + + const bufferedClient = new SearchIndexingBufferedSender(searchClient, documentKeyRetriever, { + autoFlush: true + }); + + bufferedClient.on("batchAdded", (response) => { + console.log(`Batch Added Event has been receieved: ${response}`); + }); + + bufferedClient.on("beforeDocumentSent", (response) => { + console.log(`Before Document Sent Event has been receieved: ${response}`); + }); + + bufferedClient.on("batchSucceeded", (response) => { + console.log("Batch Succeeded Event has been receieved...."); + console.log(response); + }); + + bufferedClient.on("batchFailed", (response) => { + console.log("Batch Failed Event has been receieved...."); + console.log(response); + }); + + bufferedClient.uploadDocuments([ + { + hotelId: "1", + description: + "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, " + + "and a really helpful concierge. The location is perfect -- right downtown, close to all " + + "the tourist attractions. We highly recommend this hotel.", + descriptionFr: + "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine " + + "à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein " + + "centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement " + + "cet hôtel.", + hotelName: "Fancy Stay", + category: "Luxury", + tags: ["pool", "view", "wifi", "concierge"], + parkingIncluded: false, + lastRenovationDate: new Date(2010, 5, 27), + rating: 5, + location: new GeographyPoint({ + longitude: -122.131577, + latitude: 47.678581 + }) + } + ]); + + const wait_time = DEFAULT_FLUSH_WINDOW + 5000; + console.log(`Waiting for ${wait_time} ms to meet the flush window interval....`); + await delay(wait_time); + + // When the autoFlush is set to true, the user + // has to call the dispose method to clear the + // timer. + bufferedClient.dispose(); + await indexClient.deleteIndex(TEST_INDEX_NAME); + await delay(WAIT_TIME); +} + +main(); diff --git a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js new file mode 100644 index 00000000000..2fe6cdc55de --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Manual Flush. + */ + +const { + SearchIndexingBufferedSender, + AzureKeyCredential, + SearchClient, + GeographyPoint, + SearchIndexClient +} = require("@azure/search-documents"); +const { createIndex, documentKeyRetriever, WAIT_TIME } = require("./setup"); +const { delay } = require("@azure/core-http"); +const dotenv = require("dotenv"); +dotenv.config(); + +/** + * This sample is to demonstrate the use of SearchIndexingBufferedSender. + * In this sample, the autoFlush is set to false. i.e. the user + * wants to call the flush manually. + */ +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-6"; + +async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-Without AutoFlush Sample`); + + const credential = new AzureKeyCredential(apiKey); + const searchClient = new SearchClient(endpoint, TEST_INDEX_NAME, credential); + const indexClient = new SearchIndexClient(endpoint, credential); + + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + + const bufferedClient = new SearchIndexingBufferedSender(searchClient, documentKeyRetriever, { + autoFlush: false + }); + + bufferedClient.on("batchAdded", (response) => { + console.log(`Batch Added Event has been receieved: ${response}`); + }); + + bufferedClient.on("beforeDocumentSent", (response) => { + console.log(`Before Document Sent Event has been receieved: ${response}`); + }); + + bufferedClient.on("batchSucceeded", (response) => { + console.log("Batch Succeeded Event has been receieved...."); + console.log(response); + }); + + bufferedClient.on("batchFailed", (response) => { + console.log("Batch Failed Event has been receieved...."); + console.log(response); + }); + + bufferedClient.uploadDocuments([ + { + hotelId: "1", + description: + "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, " + + "and a really helpful concierge. The location is perfect -- right downtown, close to all " + + "the tourist attractions. We highly recommend this hotel.", + descriptionFr: + "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine " + + "à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein " + + "centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement " + + "cet hôtel.", + hotelName: "Fancy Stay", + category: "Luxury", + tags: ["pool", "view", "wifi", "concierge"], + parkingIncluded: false, + lastRenovationDate: new Date(2010, 5, 27), + rating: 5, + location: new GeographyPoint({ + longitude: -122.131577, + latitude: 47.678581 + }) + } + ]); + + await bufferedClient.flush(); + bufferedClient.dispose(); + await indexClient.deleteIndex(TEST_INDEX_NAME); + await delay(WAIT_TIME); +} + +main(); diff --git a/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js b/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js new file mode 100644 index 00000000000..cc8e6832c40 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the DataSource Connection Operations. + */ + +const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); +const dotenv = require("dotenv"); +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const connectionString = process.env.CONNECTION_STRING || ""; +const dataSourceConnectionName = "example-ds-connection-sample-1"; + +async function createDataSourceConnection(dataSourceConnectionName, client) { + console.log(`Creating DS Connection Operation`); + const dataSourceConnection = { + name: dataSourceConnectionName, + description: "My Data Source 1", + type: "cosmosdb", + container: { + name: "my-container-1" + }, + connectionString + }; + await client.createDataSourceConnection(dataSourceConnection); +} + +async function getAndUpdateDataSourceConnection(dataSourceConnectionName, client) { + console.log(`Get And Update DS Connection Operation`); + const ds = await client.getDataSourceConnection(dataSourceConnectionName); + ds.container.name = "Listings_5K_KingCounty_WA"; + console.log(`Updating Container Name of Datasource Connection ${dataSourceConnectionName}`); + await client.createOrUpdateDataSourceConnection(ds); +} + +async function listDataSourceConnections(client) { + console.log(`List DS Connection Operation`); + const listOfDataSourceConnections = await client.listDataSourceConnections(); + + console.log(`List of Data Source Connections`); + console.log(`*******************************`); + for (let ds of listOfDataSourceConnections) { + console.log(`Name: ${ds.name}`); + console.log(`Description: ${ds.description}`); + console.log(`Connection String: ${ds.connectionString}`); + console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); + console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); + console.log(`Etag: ${ds.etag}`); + console.log(`DataContainer`); + console.log(`\tName: ${ds.container.name}`); + console.log(`\tQuery: ${ds.container.query}`); + console.log(); + } +} + +async function deleteDataSourceConnection(dataSourceConnectionName, client) { + console.log(`Deleting DS Connection Operation`); + await client.deleteDataSourceConnection(dataSourceConnectionName); +} + +async function main() { + console.log(`Running DS Connection Operations Sample....`); + if (!endpoint || !apiKey || !connectionString) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createDataSourceConnection(dataSourceConnectionName, client); + await getAndUpdateDataSourceConnection(dataSourceConnectionName, client); + await listDataSourceConnections(client); + } finally { + await deleteDataSourceConnection(dataSourceConnectionName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/javascript/indexOperations.js b/sdk/search/search-documents/samples/v11/javascript/indexOperations.js new file mode 100644 index 00000000000..178cabf4adb --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/indexOperations.js @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Index Operations. + */ + +const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); +const dotenv = require("dotenv"); +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const indexName = "example-index-sample-1"; + +async function createIndex(indexName, client) { + console.log(`Creating Index Operation`); + const index = { + name: indexName, + fields: [ + { + type: "Edm.String", + name: "id", + key: true + }, + { + type: "Edm.Double", + name: "awesomenessLevel", + sortable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.String", + name: "description", + searchable: true + }, + { + type: "Edm.ComplexType", + name: "details", + fields: [ + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true + } + ] + }, + { + type: "Edm.Int32", + name: "hiddenWeight", + hidden: true + } + ] + }; + await client.createIndex(index); +} + +async function getAndUpdateIndex(indexName, client) { + console.log(`Get And Update Index Operation`); + const index = await client.getIndex(indexName); + index.fields.push({ + type: "Edm.DateTimeOffset", + name: "lastUpdatedOn", + filterable: true + }); + await client.createOrUpdateIndex(index); +} + +async function getIndexStatistics(indexName, client) { + console.log(`Get Index Statistics Operation`); + const statistics = await client.getIndexStatistics(indexName); + console.log(`Document Count: ${statistics.documentCount}`); + console.log(`Storage Size: ${statistics.storageSize}`); +} + +async function getServiceStatistics(client) { + console.log(`Get Service Statistics Operation`); + const { counters, limits } = await client.getServiceStatistics(); + console.log(`Counters`); + console.log(`========`); + console.log(`\tDocument Counter`); + console.log(`\t\tUsage: ${counters.documentCounter.usage}`); + console.log(`\t\tQuota: ${counters.documentCounter.quota}`); + console.log(`\tIndex Counter`); + console.log(`\t\tUsage: ${counters.indexCounter.usage}`); + console.log(`\t\tQuota: ${counters.indexCounter.quota}`); + console.log(`\tIndexer Counter`); + console.log(`\t\tUsage: ${counters.indexerCounter.usage}`); + console.log(`\t\tQuota: ${counters.indexerCounter.quota}`); + console.log(`\tData Source Counter`); + console.log(`\t\tUsage: ${counters.dataSourceCounter.usage}`); + console.log(`\t\tQuota: ${counters.dataSourceCounter.quota}`); + console.log(`\tStorage Size Counter`); + console.log(`\t\tUsage: ${counters.storageSizeCounter.usage}`); + console.log(`\t\tQuota: ${counters.storageSizeCounter.quota}`); + console.log(`\tSynonym Map Counter`); + console.log(`\t\tUsage: ${counters.synonymMapCounter.usage}`); + console.log(`\t\tQuota: ${counters.synonymMapCounter.quota}`); + console.log(); + console.log(`Limits`); + console.log(`======`); + console.log(`\tMax Fields Per Index: ${limits.maxFieldsPerIndex}`); + console.log(`\tMax Field Nesting Depth Per Index: ${limits.maxFieldNestingDepthPerIndex}`); + console.log( + `\tMax Complex Collection Fields Per Index: ${limits.maxComplexCollectionFieldsPerIndex}` + ); + console.log( + `\tMax Complex Objects In Collections Per Document: ${limits.maxComplexObjectsInCollectionsPerDocument}` + ); +} + +async function listIndexes(client) { + console.log(`List Indexes Operation`); + const result = await client.listIndexes(); + let listOfIndexes = await result.next(); + + console.log(`List of Indexes`); + console.log(`***************`); + while (!listOfIndexes.done) { + console.log(`Name: ${listOfIndexes.value.name}`); + console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); + console.log(); + listOfIndexes = await result.next(); + } +} + +async function deleteIndex(indexName, client) { + console.log(`Deleting Index Operation`); + await client.deleteIndex(indexName); +} + +async function main() { + console.log(`Running Index Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createIndex(indexName, client); + await getAndUpdateIndex(indexName, client); + await getIndexStatistics(indexName, client); + await getServiceStatistics(client); + await listIndexes(client); + } finally { + await deleteIndex(indexName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js b/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js new file mode 100644 index 00000000000..30f8c3b6aef --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Indexer Operations. + */ + +const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); +const dotenv = require("dotenv"); +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const dataSourceName = process.env.DATA_SOURCE_NAME || ""; +const targetIndexName = process.env.TARGET_INDEX_NAME || ""; + +const indexerName = "example-indexer-sample-1"; + +async function createIndexer(indexerName, client) { + console.log(`Creating Indexer Operation`); + const indexer = { + name: indexerName, + description: "Description for Sample Indexer", + dataSourceName, + targetIndexName, + isDisabled: false + }; + await client.createIndexer(indexer); +} + +async function getAndUpdateIndexer(indexerName, client) { + console.log(`Get And Update Indexer Operation`); + const indexer = await client.getIndexer(indexerName); + indexer.isDisabled = true; + await client.createOrUpdateIndexer(indexer); + indexer.isDisabled = false; + await client.createOrUpdateIndexer(indexer); +} + +async function getIndexerStatus(indexerName, client) { + console.log(`Get Indexer Status Operation`); + const indexerStatus = await client.getIndexerStatus(indexerName); + console.log(`Status: ${indexerStatus.status}`); + console.log(`Limits`); + console.log(`******`); + console.log( + `MaxDocumentContentCharactersToExtract: ${indexerStatus.limits.maxDocumentContentCharactersToExtract}` + ); + console.log(`MaxDocumentExtractionSize: ${indexerStatus.limits.maxDocumentExtractionSize}`); + console.log(`MaxRunTime: ${indexerStatus.limits.maxRunTime}`); +} + +async function listIndexers(client) { + console.log(`List Indexers Operation`); + const listOfIndexers = await client.listIndexers(); + + console.log(`\tList of Indexers`); + console.log(`\t****************`); + for (let indexer of listOfIndexers) { + console.log(`Name: ${indexer.name}`); + console.log(`Description: ${indexer.description}`); + console.log(`Data Source Name: ${indexer.dataSourceName}`); + console.log(`Skillset Name: ${indexer.skillsetName}`); + console.log(`Target Index Name: ${indexer.targetIndexName}`); + console.log(`Indexing Schedule`); + console.log(`\tInterval: ${indexer.schedule?.interval}`); + console.log(`\tStart Time: ${indexer.schedule?.startTime}`); + console.log(`Is Disabled: ${indexer.isDisabled}`); + console.log(`ETag: ${indexer.etag}`); + console.log(`Parameters`); + console.log(`\tBatch Size: ${indexer.parameters?.batchSize}`); + console.log(`\tMax Failed Items: ${indexer.parameters?.maxFailedItems}`); + console.log(`\tMax Failed Items Per Batch: ${indexer.parameters?.maxFailedItemsPerBatch}`); + console.log(); + } +} + +async function resetIndexer(indexerName, client) { + console.log(`Reset Indexer Operation`); + await client.resetIndexer(indexerName); +} + +async function deleteIndexer(indexerName, client) { + console.log(`Deleting Indexer Operation`); + await client.deleteIndexer(indexerName); +} + +async function runIndexer(indexerName, client) { + console.log(`Run Indexer Operation`); + await client.runIndexer(indexerName); +} + +async function main() { + console.log(`Running Indexer Operations Sample....`); + if (!endpoint || !apiKey || !dataSourceName || !targetIndexName) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createIndexer(indexerName, client); + await getAndUpdateIndexer(indexerName, client); + await getIndexerStatus(indexerName, client); + await listIndexers(client); + await resetIndexer(indexerName, client); + await runIndexer(indexerName, client); + } finally { + await deleteIndexer(indexerName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/javascript/interfaces.js b/sdk/search/search-documents/samples/v11/javascript/interfaces.js new file mode 100644 index 00000000000..cb0ff5c3b54 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/interfaces.js @@ -0,0 +1 @@ +export {}; diff --git a/sdk/search/search-documents/samples/javascript/package.json b/sdk/search/search-documents/samples/v11/javascript/package.json similarity index 50% rename from sdk/search/search-documents/samples/javascript/package.json rename to sdk/search/search-documents/samples/v11/javascript/package.json index b44338ba5a5..cfe45076c45 100644 --- a/sdk/search/search-documents/samples/javascript/package.json +++ b/sdk/search/search-documents/samples/v11/javascript/package.json @@ -1,20 +1,19 @@ { - "name": "azure-search-samples-js", + "name": "azure-search-documents-samples-js", "private": true, - "version": "0.1.0", - "description": "Azure Cognitive Search client library samples for JavaScript", - "engine": { + "version": "1.0.0", + "description": "Azure Search Documents client library samples for JavaScript", + "engines": { "node": ">=12.0.0" }, "repository": { "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git" + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/search/search-documents" }, "keywords": [ - "Azure", - "Search", - "Node.js", - "JavaScript" + "azure", + "cloud" ], "author": "Microsoft Corporation", "license": "MIT", @@ -22,10 +21,9 @@ "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents", - "sideEffects": false, "dependencies": { - "@azure/search-documents": "latest", - "@azure/identity": "latest", - "dotenv": "^8.2.0" + "@azure/search-documents": "next", + "dotenv": "latest", + "@azure/core-http": "^2.0.0" } } diff --git a/sdk/search/search-documents/samples/v11/javascript/sample.env b/sdk/search/search-documents/samples/v11/javascript/sample.env new file mode 100644 index 00000000000..29e6a56a9e6 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/sample.env @@ -0,0 +1,12 @@ +# The primary key of your Azure Search account. +SEARCH_API_ADMIN_KEY= + +# (optional) The secondary key of your Azure Search account. +SEARCH_API_ADMIN_KEY_ALT= + +# The endpoint of your Azure Search account. +ENDPOINT= + +# Our tests assume that TEST_MODE is "playback" by default. You can +# change it to "record" to generate new recordings, or "live" to bypass the recorder entirely. +# TEST_MODE=playback diff --git a/sdk/search/search-documents/samples/v11/javascript/setup.js b/sdk/search/search-documents/samples/v11/javascript/setup.js new file mode 100644 index 00000000000..1a14dec50b1 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/setup.js @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Defines the utility methods. + */ + +const { KnownAnalyzerNames } = require("@azure/search-documents"); + +export const WAIT_TIME = 4000; + +export const documentKeyRetriever = (document) => { + return document.hotelId; +}; + +// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters +export async function createIndex(client, name) { + const hotelIndex = { + name, + fields: [ + { + type: "Edm.String", + name: "hotelId", + key: true, + filterable: true, + sortable: true + }, + { + type: "Edm.String", + name: "hotelName", + searchable: true, + filterable: true, + sortable: true + }, + { + type: "Edm.String", + name: "description", + searchable: true, + analyzerName: KnownAnalyzerNames.EnLucene + }, + { + type: "Edm.String", + name: "descriptionFr", + searchable: true, + analyzerName: KnownAnalyzerNames.FrLucene + }, + { + type: "Edm.String", + name: "category", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.Boolean", + name: "parkingIncluded", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.Boolean", + name: "smokingAllowed", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.DateTimeOffset", + name: "lastRenovationDate", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.Double", + name: "rating", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.GeographyPoint", + name: "location", + filterable: true, + sortable: true + }, + { + type: "Edm.ComplexType", + name: "address", + fields: [ + { + type: "Edm.String", + name: "streetAddress", + searchable: true + }, + { + type: "Edm.String", + name: "city", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.String", + name: "stateProvince", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.String", + name: "country", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.String", + name: "postalCode", + searchable: true, + filterable: true, + sortable: true, + facetable: true + } + ] + }, + { + type: "Collection(Edm.ComplexType)", + name: "rooms", + fields: [ + { + type: "Edm.String", + name: "description", + searchable: true, + analyzerName: KnownAnalyzerNames.EnLucene + }, + { + type: "Edm.String", + name: "descriptionFr", + searchable: true, + analyzerName: KnownAnalyzerNames.FrLucene + }, + { + type: "Edm.String", + name: "type", + searchable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.Double", + name: "baseRate", + filterable: true, + facetable: true + }, + { + type: "Edm.String", + name: "bedOptions", + searchable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.Int32", + name: "sleepsCount", + filterable: true, + facetable: true + }, + { + type: "Edm.Boolean", + name: "smokingAllowed", + filterable: true, + facetable: true + }, + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true, + filterable: true, + facetable: true + } + ] + } + ], + suggesters: [ + { + name: "sg", + sourceFields: ["description", "hotelName"], + searchMode: "analyzingInfixMatching" + } + ], + scoringProfiles: [ + { + name: "nearest", + functionAggregation: "sum", + functions: [ + { + type: "distance", + fieldName: "location", + boost: 2, + parameters: { + referencePointParameter: "myloc", + boostingDistance: 100 + } + } + ] + } + ], + corsOptions: { + // for browser tests + allowedOrigins: ["*"] + } + }; + await client.createIndex(hotelIndex); +} diff --git a/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js b/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js new file mode 100644 index 00000000000..7dac52d6209 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Skillset Operations. + */ + +const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); +const dotenv = require("dotenv"); +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; + +const skillsetName = "example-skillset-sample-1"; + +async function createSkillset(skillsetName, client) { + console.log(`Creating Skillset Operation`); + const skillset = { + name: skillsetName, + description: `Skillset description`, + skills: [ + { + odatatype: "#Microsoft.Skills.Text.EntityRecognitionSkill", + inputs: [ + { + name: "text", + source: "/document/merged_content" + }, + { + name: "languageCode", + source: "/document/language" + } + ], + outputs: [ + { + name: "persons", + targetName: "people" + }, + { + name: "organizations", + targetName: "organizations" + }, + { + name: "locations", + targetName: "locations" + } + ] + } + ] + }; + await client.createSkillset(skillset); +} + +async function getAndUpdateSkillset(skillsetName, client) { + console.log(`Get And Update Skillset Operation`); + const skillset = await client.getSkillset(skillsetName); + + skillset.skills[0].outputs = [ + { + name: "persons", + targetName: "people" + }, + { + name: "organizations", + targetName: "organizations" + } + ]; + + await client.createOrUpdateSkillset(skillset); +} + +async function listSkillsets(client) { + console.log(`List Skillset Operation`); + const listOfSkillsets = await client.listSkillsets(); + + console.log(`\tList of Skillsets`); + console.log(`\t******************`); + for (let skillset of listOfSkillsets) { + console.log(`Name: ${skillset.name}`); + console.log(`Description: ${skillset.description}`); + console.log(`Skills`); + console.log(`******`); + for (let skill of skillset.skills) { + console.log(`ODataType: ${skill.odatatype}`); + console.log(`Inputs`); + for (let input of skill.inputs) { + console.log(`\tName: ${input.name}`); + console.log(`\tSource: ${input.source}`); + } + console.log(`Outputs`); + for (let output of skill.outputs) { + console.log(`\tName: ${output.name}`); + console.log(`\tTarget Name: ${output.targetName}`); + } + } + } +} + +async function deleteSkillset(skillsetName, client) { + console.log(`Deleting Skillset Operation`); + await client.deleteSkillset(skillsetName); +} + +async function main() { + console.log(`Running Skillset Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createSkillset(skillsetName, client); + await getAndUpdateSkillset(skillsetName, client); + await listSkillsets(client); + } finally { + await deleteSkillset(skillsetName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js b/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js new file mode 100644 index 00000000000..461dfe2bc43 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SynonymMap Operations. + */ + +const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); +const dotenv = require("dotenv"); +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const synonymMapName = "example-synonymmap-sample-1"; + +async function createSynonymMap(synonymMapName, client) { + console.log(`Creating SynonymMap Operation`); + const sm = { + name: synonymMapName, + synonyms: ["United States, United States of America => USA", "Washington, Wash. => WA"] + }; + await client.createSynonymMap(sm); +} + +async function getAndUpdateSynonymMap(synonymMapName, client) { + console.log(`Get And Update SynonymMap Operation`); + const sm = await client.getSynonymMap(synonymMapName); + console.log(`Update synonyms Synonym Map my-synonymmap`); + sm.synonyms.push("Florida, Fld. => FL"); + await client.createOrUpdateSynonymMap(sm); +} + +async function listSynonymMaps(client) { + console.log(`List SynonymMaps Operation`); + const listOfSynonymMaps = await client.listSynonymMaps(); + + console.log(`List of SynonymMaps`); + console.log(`*******************`); + for (let sm of listOfSynonymMaps) { + console.log(`Name: ${sm.name}`); + console.log(`Synonyms`); + for (let synonym of sm.synonyms) { + console.log(synonym); + } + } +} + +async function deleteSynonymMap(synonymMapName, client) { + console.log(`Deleting SynonymMap Operation`); + await client.deleteSynonymMap(synonymMapName); +} + +async function main() { + console.log(`Running Index Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createSynonymMap(synonymMapName, client); + await getAndUpdateSynonymMap(synonymMapName, client); + await listSynonymMaps(client); + } finally { + await deleteSynonymMap(synonymMapName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/typescript/README.md b/sdk/search/search-documents/samples/v11/typescript/README.md new file mode 100644 index 00000000000..3bbd24fcda6 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/README.md @@ -0,0 +1,95 @@ +--- +page_type: sample +languages: + - typescript +products: + - azure + - azure-cognitive-search + - azure-search +urlFragment: search-documents-typescript +--- + +# Azure Search Documents client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for Azure Search Documents in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| [bufferedSenderAutoFlushSize.ts][bufferedsenderautoflushsize] | Demonstrates the SearchIndexingBufferedSender with Autoflush based on size. | +| [bufferedSenderAutoFlushTimer.ts][bufferedsenderautoflushtimer] | Demonstrates the SearchIndexingBufferedSender with Autoflush based on timer. | +| [bufferedSenderManualFlush.ts][bufferedsendermanualflush] | Demonstrates the SearchIndexingBufferedSender with Manual Flush. | +| [dataSourceConnectionOperations.ts][datasourceconnectionoperations] | Demonstrates the DataSource Connection Operations. | +| [indexOperations.ts][indexoperations] | Demonstrates the Index Operations. | +| [indexerOperations.ts][indexeroperations] | Demonstrates the Indexer Operations. | +| [interfaces.ts][interfaces] | Defines the Hotel Interface. | +| [setup.ts][setup] | Defines the utility methods. | +| [skillSetOperations.ts][skillsetoperations] | Demonstrates the Skillset Operations. | +| [synonymMapOperations.ts][synonymmapoperations] | Demonstrates the SynonymMap Operations. | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: + +- [Azure Search Documents instance][createinstance_azuresearchdocumentsinstance] + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/bufferedSenderAutoFlushSize.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env ENDPOINT="" SEARCH_API_ADMIN_KEY="" node dist/bufferedSenderAutoFlushSize.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[bufferedsenderautoflushsize]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts +[bufferedsenderautoflushtimer]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts +[bufferedsendermanualflush]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts +[datasourceconnectionoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts +[indexoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts +[indexeroperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts +[interfaces]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts +[setup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/setup.ts +[skillsetoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts +[synonymmapoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/search-documents +[freesub]: https://azure.microsoft.com/free/ +[createinstance_azuresearchdocumentsinstance]: https://docs.microsoft.com/azure/search/search-create-service-portal +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/search/search-documents/samples/typescript/package.json b/sdk/search/search-documents/samples/v11/typescript/package.json similarity index 51% rename from sdk/search/search-documents/samples/typescript/package.json rename to sdk/search/search-documents/samples/v11/typescript/package.json index 114748f2dbe..051120eea06 100644 --- a/sdk/search/search-documents/samples/typescript/package.json +++ b/sdk/search/search-documents/samples/v11/typescript/package.json @@ -1,9 +1,9 @@ { - "name": "azure-search-samples-ts", + "name": "azure-search-documents-samples-ts", "private": true, - "version": "0.1.0", - "description": "Azure Cognitive Search client library samples for TypeScript", - "engine": { + "version": "1.0.0", + "description": "Azure Search Documents client library samples for TypeScript", + "engines": { "node": ">=12.0.0" }, "scripts": { @@ -12,13 +12,12 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git" + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/search/search-documents" }, "keywords": [ - "Azure", - "Search", - "Node.js", - "TypeScript" + "azure", + "cloud" ], "author": "Microsoft Corporation", "license": "MIT", @@ -26,15 +25,13 @@ "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents", - "sideEffects": false, "dependencies": { - "@azure/search-documents": "latest", - "@azure/identity": "latest", - "dotenv": "^8.2.0" + "@azure/search-documents": "next", + "dotenv": "latest", + "@azure/core-http": "^2.0.0" }, "devDependencies": { - "@types/node": "^12.0.0", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "typescript": "~4.2.0", + "rimraf": "latest" } } diff --git a/sdk/search/search-documents/samples/v11/typescript/sample.env b/sdk/search/search-documents/samples/v11/typescript/sample.env new file mode 100644 index 00000000000..29e6a56a9e6 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/sample.env @@ -0,0 +1,12 @@ +# The primary key of your Azure Search account. +SEARCH_API_ADMIN_KEY= + +# (optional) The secondary key of your Azure Search account. +SEARCH_API_ADMIN_KEY_ALT= + +# The endpoint of your Azure Search account. +ENDPOINT= + +# Our tests assume that TEST_MODE is "playback" by default. You can +# change it to "record" to generate new recordings, or "live" to bypass the recorder entirely. +# TEST_MODE=playback diff --git a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts new file mode 100644 index 00000000000..8363c1c1d99 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Autoflush based on size. + */ + +import { + SearchIndexingBufferedSender, + AzureKeyCredential, + SearchClient, + GeographyPoint, + SearchIndexClient +} from "@azure/search-documents"; +import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { Hotel } from "./interfaces"; +import { delay } from "@azure/core-http"; +import * as dotenv from "dotenv"; +dotenv.config(); + +/** + * This sample is to demonstrate the use of SearchIndexingBufferedSender. + * In this sample, the autoFlush is set to true. i.e. the user does not + * want to call the flush manually. The upload action happen automatically + * when the size of the batch is greater than threshold (which is set to 1000) + * by default. + */ +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-4"; + +function getDocumentsArray(size: number): Hotel[] { + const array: Hotel[] = []; + for (let i = 1; i <= size; i++) { + array.push({ + hotelId: `${i}`, + description: + "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, " + + "and a really helpful concierge. The location is perfect -- right downtown, close to all " + + "the tourist attractions. We highly recommend this hotel.", + descriptionFr: + "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine " + + "à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein " + + "centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement " + + "cet hôtel.", + hotelName: "Fancy Stay", + category: "Luxury", + tags: ["pool", "view", "wifi", "concierge"], + parkingIncluded: false, + lastRenovationDate: new Date(2010, 5, 27), + rating: 5, + location: new GeographyPoint({ + longitude: -122.131577, + latitude: 47.678581 + }) + }); + } + return array; +} + +async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-With Auto Flush Sizes Sample`); + + const credential = new AzureKeyCredential(apiKey); + const searchClient: SearchClient = new SearchClient( + endpoint, + TEST_INDEX_NAME, + credential + ); + const indexClient: SearchIndexClient = new SearchIndexClient(endpoint, credential); + + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + + const bufferedClient = new SearchIndexingBufferedSender( + searchClient, + documentKeyRetriever, + { + autoFlush: true + } + ); + + bufferedClient.on("batchAdded", (response: any) => { + console.log(`Batch Added Event has been receieved: ${response}`); + }); + + bufferedClient.on("beforeDocumentSent", (response: any) => { + console.log(`Before Document Sent Event has been receieved: ${response}`); + }); + + bufferedClient.on("batchSucceeded", (response: any) => { + console.log("Batch Succeeded Event has been receieved...."); + console.log(response); + }); + + bufferedClient.on("batchFailed", (response: any) => { + console.log("Batch Failed Event has been receieved...."); + console.log(response); + }); + + const documents: Hotel[] = getDocumentsArray(1001); + bufferedClient.uploadDocuments(documents); + + await WAIT_TIME; + + let count = await searchClient.getDocumentsCount(); + while (count !== documents.length) { + await delay(WAIT_TIME); + count = await searchClient.getDocumentsCount(); + } + + // When the autoFlush is set to true, the user + // has to call the dispose method to clear the + // timer. + bufferedClient.dispose(); + await indexClient.deleteIndex(TEST_INDEX_NAME); + await delay(WAIT_TIME); +} + +main(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts new file mode 100644 index 00000000000..4317f76ef56 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Autoflush based on timer. + */ + +import { + SearchIndexingBufferedSender, + AzureKeyCredential, + SearchClient, + GeographyPoint, + SearchIndexClient, + DEFAULT_FLUSH_WINDOW +} from "@azure/search-documents"; +import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { Hotel } from "./interfaces"; +import { delay } from "@azure/core-http"; +import * as dotenv from "dotenv"; +dotenv.config(); + +/** + * This sample is to demonstrate the use of SearchIndexingBufferedSender. + * In this sample, the autoFlush is set to true. i.e. the user does not + * want to call the flush manually. The upload action happen automatically + * when the time interval is met. The time interval is set to 60000ms + * by default. + */ +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-5"; + +export async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-With Auto Flush Timer Sample`); + + const credential = new AzureKeyCredential(apiKey); + const searchClient: SearchClient = new SearchClient( + endpoint, + TEST_INDEX_NAME, + credential + ); + const indexClient: SearchIndexClient = new SearchIndexClient(endpoint, credential); + + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + + const bufferedClient: SearchIndexingBufferedSender = new SearchIndexingBufferedSender( + searchClient, + documentKeyRetriever, + { + autoFlush: true + } + ); + + bufferedClient.on("batchAdded", (response: any) => { + console.log(`Batch Added Event has been receieved: ${response}`); + }); + + bufferedClient.on("beforeDocumentSent", (response: any) => { + console.log(`Before Document Sent Event has been receieved: ${response}`); + }); + + bufferedClient.on("batchSucceeded", (response: any) => { + console.log("Batch Succeeded Event has been receieved...."); + console.log(response); + }); + + bufferedClient.on("batchFailed", (response: any) => { + console.log("Batch Failed Event has been receieved...."); + console.log(response); + }); + + bufferedClient.uploadDocuments([ + { + hotelId: "1", + description: + "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, " + + "and a really helpful concierge. The location is perfect -- right downtown, close to all " + + "the tourist attractions. We highly recommend this hotel.", + descriptionFr: + "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine " + + "à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein " + + "centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement " + + "cet hôtel.", + hotelName: "Fancy Stay", + category: "Luxury", + tags: ["pool", "view", "wifi", "concierge"], + parkingIncluded: false, + lastRenovationDate: new Date(2010, 5, 27), + rating: 5, + location: new GeographyPoint({ + longitude: -122.131577, + latitude: 47.678581 + }) + } + ]); + + const wait_time = DEFAULT_FLUSH_WINDOW + 5000; + console.log(`Waiting for ${wait_time} ms to meet the flush window interval....`); + await delay(wait_time); + + // When the autoFlush is set to true, the user + // has to call the dispose method to clear the + // timer. + bufferedClient.dispose(); + await indexClient.deleteIndex(TEST_INDEX_NAME); + await delay(WAIT_TIME); +} + +main(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts new file mode 100644 index 00000000000..995e45b236e --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SearchIndexingBufferedSender with Manual Flush. + */ + +import { + SearchIndexingBufferedSender, + AzureKeyCredential, + SearchClient, + GeographyPoint, + SearchIndexClient +} from "@azure/search-documents"; +import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { Hotel } from "./interfaces"; +import { delay } from "@azure/core-http"; +import * as dotenv from "dotenv"; +dotenv.config(); + +/** + * This sample is to demonstrate the use of SearchIndexingBufferedSender. + * In this sample, the autoFlush is set to false. i.e. the user + * wants to call the flush manually. + */ +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const TEST_INDEX_NAME = "example-index-sample-6"; + +export async function main() { + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + + console.log(`Running SearchIndexingBufferedSender-uploadDocuments-Without AutoFlush Sample`); + + const credential = new AzureKeyCredential(apiKey); + const searchClient: SearchClient = new SearchClient( + endpoint, + TEST_INDEX_NAME, + credential + ); + const indexClient: SearchIndexClient = new SearchIndexClient(endpoint, credential); + + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + + const bufferedClient: SearchIndexingBufferedSender = new SearchIndexingBufferedSender( + searchClient, + documentKeyRetriever, + { + autoFlush: false + } + ); + + bufferedClient.on("batchAdded", (response: any) => { + console.log(`Batch Added Event has been receieved: ${response}`); + }); + + bufferedClient.on("beforeDocumentSent", (response: any) => { + console.log(`Before Document Sent Event has been receieved: ${response}`); + }); + + bufferedClient.on("batchSucceeded", (response: any) => { + console.log("Batch Succeeded Event has been receieved...."); + console.log(response); + }); + + bufferedClient.on("batchFailed", (response: any) => { + console.log("Batch Failed Event has been receieved...."); + console.log(response); + }); + + bufferedClient.uploadDocuments([ + { + hotelId: "1", + description: + "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, " + + "and a really helpful concierge. The location is perfect -- right downtown, close to all " + + "the tourist attractions. We highly recommend this hotel.", + descriptionFr: + "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine " + + "à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein " + + "centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement " + + "cet hôtel.", + hotelName: "Fancy Stay", + category: "Luxury", + tags: ["pool", "view", "wifi", "concierge"], + parkingIncluded: false, + lastRenovationDate: new Date(2010, 5, 27), + rating: 5, + location: new GeographyPoint({ + longitude: -122.131577, + latitude: 47.678581 + }) + } + ]); + + await bufferedClient.flush(); + bufferedClient.dispose(); + await indexClient.deleteIndex(TEST_INDEX_NAME); + await delay(WAIT_TIME); +} + +main(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts new file mode 100644 index 00000000000..20724b11029 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the DataSource Connection Operations. + */ + +import { + SearchIndexerClient, + AzureKeyCredential, + SearchIndexerDataSourceConnection +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const connectionString = process.env.CONNECTION_STRING || ""; +const dataSourceConnectionName = "example-ds-connection-sample-1"; + +async function createDataSourceConnection( + dataSourceConnectionName: string, + client: SearchIndexerClient +) { + console.log(`Creating DS Connection Operation`); + const dataSourceConnection: SearchIndexerDataSourceConnection = { + name: dataSourceConnectionName, + description: "My Data Source 1", + type: "cosmosdb", + container: { + name: "my-container-1" + }, + connectionString + }; + await client.createDataSourceConnection(dataSourceConnection); +} + +async function getAndUpdateDataSourceConnection( + dataSourceConnectionName: string, + client: SearchIndexerClient +) { + console.log(`Get And Update DS Connection Operation`); + const ds: SearchIndexerDataSourceConnection = await client.getDataSourceConnection( + dataSourceConnectionName + ); + ds.container.name = "Listings_5K_KingCounty_WA"; + console.log(`Updating Container Name of Datasource Connection ${dataSourceConnectionName}`); + await client.createOrUpdateDataSourceConnection(ds); +} + +async function listDataSourceConnections(client: SearchIndexerClient) { + console.log(`List DS Connection Operation`); + const listOfDataSourceConnections: Array = await client.listDataSourceConnections(); + + console.log(`List of Data Source Connections`); + console.log(`*******************************`); + for (let ds of listOfDataSourceConnections) { + console.log(`Name: ${ds.name}`); + console.log(`Description: ${ds.description}`); + console.log(`Connection String: ${ds.connectionString}`); + console.log(`Data Change Detection Policy: ${ds.dataChangeDetectionPolicy}`); + console.log(`Data Deletion Detection Policy: ${ds.dataDeletionDetectionPolicy}`); + console.log(`Etag: ${ds.etag}`); + console.log(`DataContainer`); + console.log(`\tName: ${ds.container.name}`); + console.log(`\tQuery: ${ds.container.query}`); + console.log(); + } +} + +async function deleteDataSourceConnection( + dataSourceConnectionName: string, + client: SearchIndexerClient +) { + console.log(`Deleting DS Connection Operation`); + await client.deleteDataSourceConnection(dataSourceConnectionName); +} + +async function main() { + console.log(`Running DS Connection Operations Sample....`); + if (!endpoint || !apiKey || !connectionString) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createDataSourceConnection(dataSourceConnectionName, client); + await getAndUpdateDataSourceConnection(dataSourceConnectionName, client); + await listDataSourceConnections(client); + } finally { + await deleteDataSourceConnection(dataSourceConnectionName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts new file mode 100644 index 00000000000..89aec8a8ef6 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Index Operations. + */ + +import { + SearchIndexClient, + AzureKeyCredential, + SearchIndex, + SearchIndexStatistics +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const indexName = "example-index-sample-1"; + +async function createIndex(indexName: string, client: SearchIndexClient) { + console.log(`Creating Index Operation`); + const index: SearchIndex = { + name: indexName, + fields: [ + { + type: "Edm.String", + name: "id", + key: true + }, + { + type: "Edm.Double", + name: "awesomenessLevel", + sortable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.String", + name: "description", + searchable: true + }, + { + type: "Edm.ComplexType", + name: "details", + fields: [ + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true + } + ] + }, + { + type: "Edm.Int32", + name: "hiddenWeight", + hidden: true + } + ] + }; + await client.createIndex(index); +} + +async function getAndUpdateIndex(indexName: string, client: SearchIndexClient) { + console.log(`Get And Update Index Operation`); + const index: SearchIndex = await client.getIndex(indexName); + index.fields.push({ + type: "Edm.DateTimeOffset", + name: "lastUpdatedOn", + filterable: true + }); + await client.createOrUpdateIndex(index); +} + +async function getIndexStatistics(indexName: string, client: SearchIndexClient) { + console.log(`Get Index Statistics Operation`); + const statistics: SearchIndexStatistics = await client.getIndexStatistics(indexName); + console.log(`Document Count: ${statistics.documentCount}`); + console.log(`Storage Size: ${statistics.storageSize}`); +} + +async function getServiceStatistics(client: SearchIndexClient) { + console.log(`Get Service Statistics Operation`); + const { counters, limits } = await client.getServiceStatistics(); + console.log(`Counters`); + console.log(`========`); + console.log(`\tDocument Counter`); + console.log(`\t\tUsage: ${counters.documentCounter.usage}`); + console.log(`\t\tQuota: ${counters.documentCounter.quota}`); + console.log(`\tIndex Counter`); + console.log(`\t\tUsage: ${counters.indexCounter.usage}`); + console.log(`\t\tQuota: ${counters.indexCounter.quota}`); + console.log(`\tIndexer Counter`); + console.log(`\t\tUsage: ${counters.indexerCounter.usage}`); + console.log(`\t\tQuota: ${counters.indexerCounter.quota}`); + console.log(`\tData Source Counter`); + console.log(`\t\tUsage: ${counters.dataSourceCounter.usage}`); + console.log(`\t\tQuota: ${counters.dataSourceCounter.quota}`); + console.log(`\tStorage Size Counter`); + console.log(`\t\tUsage: ${counters.storageSizeCounter.usage}`); + console.log(`\t\tQuota: ${counters.storageSizeCounter.quota}`); + console.log(`\tSynonym Map Counter`); + console.log(`\t\tUsage: ${counters.synonymMapCounter.usage}`); + console.log(`\t\tQuota: ${counters.synonymMapCounter.quota}`); + console.log(); + console.log(`Limits`); + console.log(`======`); + console.log(`\tMax Fields Per Index: ${limits.maxFieldsPerIndex}`); + console.log(`\tMax Field Nesting Depth Per Index: ${limits.maxFieldNestingDepthPerIndex}`); + console.log( + `\tMax Complex Collection Fields Per Index: ${limits.maxComplexCollectionFieldsPerIndex}` + ); + console.log( + `\tMax Complex Objects In Collections Per Document: ${limits.maxComplexObjectsInCollectionsPerDocument}` + ); +} + +async function listIndexes(client: SearchIndexClient) { + console.log(`List Indexes Operation`); + const result = await client.listIndexes(); + let listOfIndexes = await result.next(); + + console.log(`List of Indexes`); + console.log(`***************`); + while (!listOfIndexes.done) { + console.log(`Name: ${listOfIndexes.value.name}`); + console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); + console.log(); + listOfIndexes = await result.next(); + } +} + +async function deleteIndex(indexName: string, client: SearchIndexClient) { + console.log(`Deleting Index Operation`); + await client.deleteIndex(indexName); +} + +async function main() { + console.log(`Running Index Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createIndex(indexName, client); + await getAndUpdateIndex(indexName, client); + await getIndexStatistics(indexName, client); + await getServiceStatistics(client); + await listIndexes(client); + } finally { + await deleteIndex(indexName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts new file mode 100644 index 00000000000..f1530883c88 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Indexer Operations. + */ + +import { + SearchIndexerClient, + AzureKeyCredential, + SearchIndexer, + SearchIndexerStatus +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const dataSourceName = process.env.DATA_SOURCE_NAME || ""; +const targetIndexName = process.env.TARGET_INDEX_NAME || ""; + +const indexerName = "example-indexer-sample-1"; + +async function createIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Creating Indexer Operation`); + const indexer: SearchIndexer = { + name: indexerName, + description: "Description for Sample Indexer", + dataSourceName, + targetIndexName, + isDisabled: false + }; + await client.createIndexer(indexer); +} + +async function getAndUpdateIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Get And Update Indexer Operation`); + const indexer: SearchIndexer = await client.getIndexer(indexerName); + indexer.isDisabled = true; + await client.createOrUpdateIndexer(indexer); + indexer.isDisabled = false; + await client.createOrUpdateIndexer(indexer); +} + +async function getIndexerStatus(indexerName: string, client: SearchIndexerClient) { + console.log(`Get Indexer Status Operation`); + const indexerStatus: SearchIndexerStatus = await client.getIndexerStatus(indexerName); + console.log(`Status: ${indexerStatus.status}`); + console.log(`Limits`); + console.log(`******`); + console.log( + `MaxDocumentContentCharactersToExtract: ${indexerStatus.limits.maxDocumentContentCharactersToExtract}` + ); + console.log(`MaxDocumentExtractionSize: ${indexerStatus.limits.maxDocumentExtractionSize}`); + console.log(`MaxRunTime: ${indexerStatus.limits.maxRunTime}`); +} + +async function listIndexers(client: SearchIndexerClient) { + console.log(`List Indexers Operation`); + const listOfIndexers: Array = await client.listIndexers(); + + console.log(`\tList of Indexers`); + console.log(`\t****************`); + for (let indexer of listOfIndexers) { + console.log(`Name: ${indexer.name}`); + console.log(`Description: ${indexer.description}`); + console.log(`Data Source Name: ${indexer.dataSourceName}`); + console.log(`Skillset Name: ${indexer.skillsetName}`); + console.log(`Target Index Name: ${indexer.targetIndexName}`); + console.log(`Indexing Schedule`); + console.log(`\tInterval: ${indexer.schedule?.interval}`); + console.log(`\tStart Time: ${indexer.schedule?.startTime}`); + console.log(`Is Disabled: ${indexer.isDisabled}`); + console.log(`ETag: ${indexer.etag}`); + console.log(`Parameters`); + console.log(`\tBatch Size: ${indexer.parameters?.batchSize}`); + console.log(`\tMax Failed Items: ${indexer.parameters?.maxFailedItems}`); + console.log(`\tMax Failed Items Per Batch: ${indexer.parameters?.maxFailedItemsPerBatch}`); + console.log(); + } +} + +async function resetIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Reset Indexer Operation`); + await client.resetIndexer(indexerName); +} + +async function deleteIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Deleting Indexer Operation`); + await client.deleteIndexer(indexerName); +} + +async function runIndexer(indexerName: string, client: SearchIndexerClient) { + console.log(`Run Indexer Operation`); + await client.runIndexer(indexerName); +} + +async function main() { + console.log(`Running Indexer Operations Sample....`); + if (!endpoint || !apiKey || !dataSourceName || !targetIndexName) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createIndexer(indexerName, client); + await getAndUpdateIndexer(indexerName, client); + await getIndexerStatus(indexerName, client); + await listIndexers(client); + await resetIndexer(indexerName, client); + await runIndexer(indexerName, client); + } finally { + await deleteIndexer(indexerName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts b/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts new file mode 100644 index 00000000000..1230fa50a70 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Defines the Hotel Interface. + */ + +import { GeographyPoint } from "@azure/search-documents"; + +export interface Hotel { + hotelId: string; + hotelName?: string | null; + description?: string | null; + descriptionFr?: string | null; + category?: string | null; + tags?: string[] | null; + parkingIncluded?: boolean | null; + smokingAllowed?: boolean | null; + lastRenovationDate?: Date | null; + rating?: number | null; + location?: GeographyPoint | null; + address?: { + streetAddress?: string | null; + city?: string | null; + stateProvince?: string | null; + postalCode?: string | null; + country?: string | null; + } | null; + rooms?: Array<{ + description?: string | null; + descriptionFr?: string | null; + type?: string | null; + baseRate?: number | null; + bedOptions?: string | null; + sleepsCount?: number | null; + smokingAllowed?: boolean | null; + tags?: string[] | null; + }> | null; +} diff --git a/sdk/search/search-documents/samples/v11/typescript/src/setup.ts b/sdk/search/search-documents/samples/v11/typescript/src/setup.ts new file mode 100644 index 00000000000..d5478f2d986 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/setup.ts @@ -0,0 +1,228 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Defines the utility methods. + */ + +import { SearchIndexClient, SearchIndex, KnownAnalyzerNames } from "@azure/search-documents"; +import { Hotel } from "./interfaces"; + +export const WAIT_TIME = 4000; + +export const documentKeyRetriever: (document: Hotel) => string = (document: Hotel): string => { + return document.hotelId; +}; + +// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters +export async function createIndex(client: SearchIndexClient, name: string): Promise { + const hotelIndex: SearchIndex = { + name, + fields: [ + { + type: "Edm.String", + name: "hotelId", + key: true, + filterable: true, + sortable: true + }, + { + type: "Edm.String", + name: "hotelName", + searchable: true, + filterable: true, + sortable: true + }, + { + type: "Edm.String", + name: "description", + searchable: true, + analyzerName: KnownAnalyzerNames.EnLucene + }, + { + type: "Edm.String", + name: "descriptionFr", + searchable: true, + analyzerName: KnownAnalyzerNames.FrLucene + }, + { + type: "Edm.String", + name: "category", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.Boolean", + name: "parkingIncluded", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.Boolean", + name: "smokingAllowed", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.DateTimeOffset", + name: "lastRenovationDate", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.Double", + name: "rating", + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.GeographyPoint", + name: "location", + filterable: true, + sortable: true + }, + { + type: "Edm.ComplexType", + name: "address", + fields: [ + { + type: "Edm.String", + name: "streetAddress", + searchable: true + }, + { + type: "Edm.String", + name: "city", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.String", + name: "stateProvince", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.String", + name: "country", + searchable: true, + filterable: true, + sortable: true, + facetable: true + }, + { + type: "Edm.String", + name: "postalCode", + searchable: true, + filterable: true, + sortable: true, + facetable: true + } + ] + }, + { + type: "Collection(Edm.ComplexType)", + name: "rooms", + fields: [ + { + type: "Edm.String", + name: "description", + searchable: true, + analyzerName: KnownAnalyzerNames.EnLucene + }, + { + type: "Edm.String", + name: "descriptionFr", + searchable: true, + analyzerName: KnownAnalyzerNames.FrLucene + }, + { + type: "Edm.String", + name: "type", + searchable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.Double", + name: "baseRate", + filterable: true, + facetable: true + }, + { + type: "Edm.String", + name: "bedOptions", + searchable: true, + filterable: true, + facetable: true + }, + { + type: "Edm.Int32", + name: "sleepsCount", + filterable: true, + facetable: true + }, + { + type: "Edm.Boolean", + name: "smokingAllowed", + filterable: true, + facetable: true + }, + { + type: "Collection(Edm.String)", + name: "tags", + searchable: true, + filterable: true, + facetable: true + } + ] + } + ], + suggesters: [ + { + name: "sg", + sourceFields: ["description", "hotelName"], + searchMode: "analyzingInfixMatching" + } + ], + scoringProfiles: [ + { + name: "nearest", + functionAggregation: "sum", + functions: [ + { + type: "distance", + fieldName: "location", + boost: 2, + parameters: { + referencePointParameter: "myloc", + boostingDistance: 100 + } + } + ] + } + ], + corsOptions: { + // for browser tests + allowedOrigins: ["*"] + } + }; + await client.createIndex(hotelIndex); +} diff --git a/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts new file mode 100644 index 00000000000..8bf587fde6e --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the Skillset Operations. + */ + +import { + SearchIndexerClient, + AzureKeyCredential, + SearchIndexerSkillset +} from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; + +const skillsetName = "example-skillset-sample-1"; + +async function createSkillset(skillsetName: string, client: SearchIndexerClient) { + console.log(`Creating Skillset Operation`); + const skillset: SearchIndexerSkillset = { + name: skillsetName, + description: `Skillset description`, + skills: [ + { + odatatype: "#Microsoft.Skills.Text.EntityRecognitionSkill", + inputs: [ + { + name: "text", + source: "/document/merged_content" + }, + { + name: "languageCode", + source: "/document/language" + } + ], + outputs: [ + { + name: "persons", + targetName: "people" + }, + { + name: "organizations", + targetName: "organizations" + }, + { + name: "locations", + targetName: "locations" + } + ] + } + ] + }; + await client.createSkillset(skillset); +} + +async function getAndUpdateSkillset(skillsetName: string, client: SearchIndexerClient) { + console.log(`Get And Update Skillset Operation`); + const skillset: SearchIndexerSkillset = await client.getSkillset(skillsetName); + + skillset.skills[0].outputs = [ + { + name: "persons", + targetName: "people" + }, + { + name: "organizations", + targetName: "organizations" + } + ]; + + await client.createOrUpdateSkillset(skillset); +} + +async function listSkillsets(client: SearchIndexerClient) { + console.log(`List Skillset Operation`); + const listOfSkillsets: Array = await client.listSkillsets(); + + console.log(`\tList of Skillsets`); + console.log(`\t******************`); + for (let skillset of listOfSkillsets) { + console.log(`Name: ${skillset.name}`); + console.log(`Description: ${skillset.description}`); + console.log(`Skills`); + console.log(`******`); + for (let skill of skillset.skills) { + console.log(`ODataType: ${skill.odatatype}`); + console.log(`Inputs`); + for (let input of skill.inputs) { + console.log(`\tName: ${input.name}`); + console.log(`\tSource: ${input.source}`); + } + console.log(`Outputs`); + for (let output of skill.outputs) { + console.log(`\tName: ${output.name}`); + console.log(`\tTarget Name: ${output.targetName}`); + } + } + } +} + +async function deleteSkillset(skillsetName: string, client: SearchIndexerClient) { + console.log(`Deleting Skillset Operation`); + await client.deleteSkillset(skillsetName); +} + +async function main() { + console.log(`Running Skillset Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createSkillset(skillsetName, client); + await getAndUpdateSkillset(skillsetName, client); + await listSkillsets(client); + } finally { + await deleteSkillset(skillsetName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts new file mode 100644 index 00000000000..bc3dcac9681 --- /dev/null +++ b/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @summary Demonstrates the SynonymMap Operations. + */ + +import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents"; +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env.ENDPOINT || ""; +const apiKey = process.env.SEARCH_API_ADMIN_KEY || ""; +const synonymMapName = "example-synonymmap-sample-1"; + +async function createSynonymMap(synonymMapName: string, client: SearchIndexClient) { + console.log(`Creating SynonymMap Operation`); + const sm: SynonymMap = { + name: synonymMapName, + synonyms: ["United States, United States of America => USA", "Washington, Wash. => WA"] + }; + await client.createSynonymMap(sm); +} + +async function getAndUpdateSynonymMap(synonymMapName: string, client: SearchIndexClient) { + console.log(`Get And Update SynonymMap Operation`); + const sm: SynonymMap = await client.getSynonymMap(synonymMapName); + console.log(`Update synonyms Synonym Map my-synonymmap`); + sm.synonyms.push("Florida, Fld. => FL"); + await client.createOrUpdateSynonymMap(sm); +} + +async function listSynonymMaps(client: SearchIndexClient) { + console.log(`List SynonymMaps Operation`); + const listOfSynonymMaps: Array = await client.listSynonymMaps(); + + console.log(`List of SynonymMaps`); + console.log(`*******************`); + for (let sm of listOfSynonymMaps) { + console.log(`Name: ${sm.name}`); + console.log(`Synonyms`); + for (let synonym of sm.synonyms) { + console.log(synonym); + } + } +} + +async function deleteSynonymMap(synonymMapName: string, client: SearchIndexClient) { + console.log(`Deleting SynonymMap Operation`); + await client.deleteSynonymMap(synonymMapName); +} + +async function main() { + console.log(`Running Index Operations Sample....`); + if (!endpoint || !apiKey) { + console.log("Make sure to set valid values for endpoint and apiKey with proper authorization."); + return; + } + const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey)); + try { + await createSynonymMap(synonymMapName, client); + await getAndUpdateSynonymMap(synonymMapName, client); + await listSynonymMaps(client); + } finally { + await deleteSynonymMap(synonymMapName, client); + } +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/search/search-documents/samples/typescript/tsconfig.json b/sdk/search/search-documents/samples/v11/typescript/tsconfig.json similarity index 69% rename from sdk/search/search-documents/samples/typescript/tsconfig.json rename to sdk/search/search-documents/samples/v11/typescript/tsconfig.json index 4b0b2a6d1e8..416c2dd82e0 100644 --- a/sdk/search/search-documents/samples/typescript/tsconfig.json +++ b/sdk/search/search-documents/samples/v11/typescript/tsconfig.json @@ -1,7 +1,10 @@ { "compilerOptions": { + "target": "ES2018", "module": "commonjs", "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "alwaysStrict": true, @@ -9,8 +12,6 @@ "rootDir": "src" }, "include": [ - "src/**.ts", - "src/**/**.ts" - ], - "exclude": ["node_modules"] + "src/**.ts" + ] } diff --git a/sdk/search/search-documents/tsconfig.json b/sdk/search/search-documents/tsconfig.json index 733a8ef3252..2249af41759 100644 --- a/sdk/search/search-documents/tsconfig.json +++ b/sdk/search/search-documents/tsconfig.json @@ -2,7 +2,10 @@ "extends": "../../../tsconfig.package", "compilerOptions": { "outDir": "./dist-esm", - "declarationDir": "./types" + "declarationDir": "./types", + "paths": { + "@azure/search-documents": ["./src/index"] + } }, - "exclude": ["node_modules", "types", "temp", "browser", "dist", "dist-esm", "./samples/**/*.ts"] + "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] }