diff --git a/sdk/search/search-documents/package.json b/sdk/search/search-documents/package.json index 1493e29b4e43..9004b91f3c07 100644 --- a/sdk/search/search-documents/package.json +++ b/sdk/search/search-documents/package.json @@ -141,7 +141,6 @@ ], "requiredResources": { "Azure Search Documents instance": "https://docs.microsoft.com/azure/search/search-create-service-portal" - }, - "skipFolder": true + } } } diff --git a/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts index 1c8b36a81af4..b54381521708 100644 --- a/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts +++ b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushSize.ts @@ -14,6 +14,7 @@ import { } from "@azure/search-documents"; import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup"; import { Hotel } from "./interfaces"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts index a6ceda98360e..c9a1f2391291 100644 --- a/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts +++ b/sdk/search/search-documents/samples-dev/bufferedSenderAutoFlushTimer.ts @@ -15,6 +15,7 @@ import { } from "@azure/search-documents"; import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup"; import { Hotel } from "./interfaces"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts b/sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts index 3bcb3857c728..c289c4d6c957 100644 --- a/sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts +++ b/sdk/search/search-documents/samples-dev/bufferedSenderManualFlush.ts @@ -14,6 +14,7 @@ import { } from "@azure/search-documents"; import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup"; import { Hotel } from "./interfaces"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts b/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts index 20724b110293..8b0416617bc1 100644 --- a/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts +++ b/sdk/search/search-documents/samples-dev/dataSourceConnectionOperations.ts @@ -10,6 +10,7 @@ import { AzureKeyCredential, SearchIndexerDataSourceConnection } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples-dev/indexOperations.ts b/sdk/search/search-documents/samples-dev/indexOperations.ts index 89aec8a8ef65..4c1c8905cce6 100644 --- a/sdk/search/search-documents/samples-dev/indexOperations.ts +++ b/sdk/search/search-documents/samples-dev/indexOperations.ts @@ -11,6 +11,7 @@ import { SearchIndex, SearchIndexStatistics } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); @@ -123,8 +124,9 @@ async function listIndexes(client: SearchIndexClient) { console.log(`List of Indexes`); console.log(`***************`); while (!listOfIndexes.done) { + const { similarity } = listOfIndexes.value; console.log(`Name: ${listOfIndexes.value.name}`); - console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); + console.log(`Similarity Algorithm: ${similarity && similarity.odatatype}`); console.log(); listOfIndexes = await result.next(); } diff --git a/sdk/search/search-documents/samples-dev/indexerOperations.ts b/sdk/search/search-documents/samples-dev/indexerOperations.ts index f1530883c886..52b41fcd9ee4 100644 --- a/sdk/search/search-documents/samples-dev/indexerOperations.ts +++ b/sdk/search/search-documents/samples-dev/indexerOperations.ts @@ -11,6 +11,7 @@ import { SearchIndexer, SearchIndexerStatus } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); @@ -61,21 +62,22 @@ async function listIndexers(client: SearchIndexerClient) { console.log(`\tList of Indexers`); console.log(`\t****************`); - for (let indexer of listOfIndexers) { + for (const indexer of listOfIndexers) { + const { schedule, parameters } = indexer; 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(`\tInterval: ${schedule && schedule.interval}`); + console.log(`\tStart Time: ${schedule && 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(`\tBatch Size: ${parameters && parameters.batchSize}`); + console.log(`\tMax Failed Items: ${parameters && parameters.maxFailedItems}`); + console.log(`\tMax Failed Items Per Batch: ${parameters && parameters.maxFailedItemsPerBatch}`); console.log(); } } diff --git a/sdk/search/search-documents/samples-dev/interfaces.ts b/sdk/search/search-documents/samples-dev/interfaces.ts index 1230fa50a70c..708f57215be9 100644 --- a/sdk/search/search-documents/samples-dev/interfaces.ts +++ b/sdk/search/search-documents/samples-dev/interfaces.ts @@ -2,7 +2,10 @@ // Licensed under the MIT license. /** - * @summary Defines the Hotel Interface. + * Defines the Hotel Interface. + * + * @azsdk-skip-javascript + * @azsdk-util */ import { GeographyPoint } from "@azure/search-documents"; diff --git a/sdk/search/search-documents/samples-dev/setup.ts b/sdk/search/search-documents/samples-dev/setup.ts index 348a874c9938..472cfa45ed4f 100644 --- a/sdk/search/search-documents/samples-dev/setup.ts +++ b/sdk/search/search-documents/samples-dev/setup.ts @@ -2,7 +2,8 @@ // Licensed under the MIT license. /** - * @summary Defines the utility methods. + * Defines the utility methods. + * @azsdk-util */ import { SearchIndexClient, SearchIndex, KnownAnalyzerNames } from "@azure/search-documents"; @@ -20,7 +21,7 @@ export const documentKeyRetriever: (document: Hotel) => string = (document: Hote * @returns Promise that is resolved after timeInMs */ export function delay(timeInMs: number): Promise { - return new Promise((resolve) => setTimeout(() => resolve(), timeInMs)); + return new Promise((resolve) => setTimeout(resolve, timeInMs)); } // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diff --git a/sdk/search/search-documents/samples-dev/skillSetOperations.ts b/sdk/search/search-documents/samples-dev/skillSetOperations.ts index 8bf587fde6ec..488b381c75ba 100644 --- a/sdk/search/search-documents/samples-dev/skillSetOperations.ts +++ b/sdk/search/search-documents/samples-dev/skillSetOperations.ts @@ -10,6 +10,7 @@ import { AzureKeyCredential, SearchIndexerSkillset } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples-dev/synonymMapOperations.ts b/sdk/search/search-documents/samples-dev/synonymMapOperations.ts index bc3dcac96818..3609f20c8344 100644 --- a/sdk/search/search-documents/samples-dev/synonymMapOperations.ts +++ b/sdk/search/search-documents/samples-dev/synonymMapOperations.ts @@ -6,6 +6,7 @@ */ import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples/v11/javascript/README.md b/sdk/search/search-documents/samples/v11/javascript/README.md index 7dbc39627883..13e20c136993 100644 --- a/sdk/search/search-documents/samples/v11/javascript/README.md +++ b/sdk/search/search-documents/samples/v11/javascript/README.md @@ -21,8 +21,6 @@ These sample programs show how to use the JavaScript client libraries for Azure | [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. | @@ -72,8 +70,6 @@ Take a look at our [API Documentation][apiref] for more information about the AP [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 diff --git a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js index c6e377b21353..00bb1b748871 100644 --- a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js +++ b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushSize.js @@ -10,10 +10,10 @@ const { AzureKeyCredential, SearchClient, GeographyPoint, - SearchIndexClient + SearchIndexClient, } = require("@azure/search-documents"); -const { createIndex, documentKeyRetriever, WAIT_TIME } = require("./setup"); -const { delay } = require("@azure/core-http"); +const { createIndex, documentKeyRetriever, WAIT_TIME, delay } = require("./setup"); + const dotenv = require("dotenv"); dotenv.config(); @@ -50,8 +50,8 @@ function getDocumentsArray(size) { rating: 5, location: new GeographyPoint({ longitude: -122.131577, - latitude: 47.678581 - }) + latitude: 47.678581, + }), }); } return array; @@ -73,7 +73,7 @@ async function main() { await delay(WAIT_TIME); const bufferedClient = new SearchIndexingBufferedSender(searchClient, documentKeyRetriever, { - autoFlush: true + autoFlush: true, }); bufferedClient.on("batchAdded", (response) => { diff --git a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js index 9321cc884de9..95693afafef9 100644 --- a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js +++ b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderAutoFlushTimer.js @@ -11,10 +11,10 @@ const { SearchClient, GeographyPoint, SearchIndexClient, - DEFAULT_FLUSH_WINDOW + DEFAULT_FLUSH_WINDOW, } = require("@azure/search-documents"); -const { createIndex, documentKeyRetriever, WAIT_TIME } = require("./setup"); -const { delay } = require("@azure/core-http"); +const { createIndex, documentKeyRetriever, WAIT_TIME, delay } = require("./setup"); + const dotenv = require("dotenv"); dotenv.config(); @@ -45,7 +45,7 @@ async function main() { await delay(WAIT_TIME); const bufferedClient = new SearchIndexingBufferedSender(searchClient, documentKeyRetriever, { - autoFlush: true + autoFlush: true, }); bufferedClient.on("batchAdded", (response) => { @@ -86,9 +86,9 @@ async function main() { rating: 5, location: new GeographyPoint({ longitude: -122.131577, - latitude: 47.678581 - }) - } + latitude: 47.678581, + }), + }, ]); const wait_time = DEFAULT_FLUSH_WINDOW + 5000; diff --git a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js index 2fe6cdc55def..52ead9e3bea7 100644 --- a/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js +++ b/sdk/search/search-documents/samples/v11/javascript/bufferedSenderManualFlush.js @@ -10,10 +10,10 @@ const { AzureKeyCredential, SearchClient, GeographyPoint, - SearchIndexClient + SearchIndexClient, } = require("@azure/search-documents"); -const { createIndex, documentKeyRetriever, WAIT_TIME } = require("./setup"); -const { delay } = require("@azure/core-http"); +const { createIndex, documentKeyRetriever, WAIT_TIME, delay } = require("./setup"); + const dotenv = require("dotenv"); dotenv.config(); @@ -42,7 +42,7 @@ async function main() { await delay(WAIT_TIME); const bufferedClient = new SearchIndexingBufferedSender(searchClient, documentKeyRetriever, { - autoFlush: false + autoFlush: false, }); bufferedClient.on("batchAdded", (response) => { @@ -83,9 +83,9 @@ async function main() { rating: 5, location: new GeographyPoint({ longitude: -122.131577, - latitude: 47.678581 - }) - } + latitude: 47.678581, + }), + }, ]); await bufferedClient.flush(); diff --git a/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js b/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js index cc8e6832c404..8b0c6697a62e 100644 --- a/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js +++ b/sdk/search/search-documents/samples/v11/javascript/dataSourceConnectionOperations.js @@ -6,6 +6,7 @@ */ const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); + const dotenv = require("dotenv"); dotenv.config(); @@ -21,9 +22,9 @@ async function createDataSourceConnection(dataSourceConnectionName, client) { description: "My Data Source 1", type: "cosmosdb", container: { - name: "my-container-1" + name: "my-container-1", }, - connectionString + connectionString, }; await client.createDataSourceConnection(dataSourceConnection); } diff --git a/sdk/search/search-documents/samples/v11/javascript/indexOperations.js b/sdk/search/search-documents/samples/v11/javascript/indexOperations.js index 178cabf4adb3..d19d545bfe9d 100644 --- a/sdk/search/search-documents/samples/v11/javascript/indexOperations.js +++ b/sdk/search/search-documents/samples/v11/javascript/indexOperations.js @@ -6,6 +6,7 @@ */ const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); + const dotenv = require("dotenv"); dotenv.config(); @@ -21,19 +22,19 @@ async function createIndex(indexName, client) { { type: "Edm.String", name: "id", - key: true + key: true, }, { type: "Edm.Double", name: "awesomenessLevel", sortable: true, filterable: true, - facetable: true + facetable: true, }, { type: "Edm.String", name: "description", - searchable: true + searchable: true, }, { type: "Edm.ComplexType", @@ -42,16 +43,16 @@ async function createIndex(indexName, client) { { type: "Collection(Edm.String)", name: "tags", - searchable: true - } - ] + searchable: true, + }, + ], }, { type: "Edm.Int32", name: "hiddenWeight", - hidden: true - } - ] + hidden: true, + }, + ], }; await client.createIndex(index); } @@ -62,7 +63,7 @@ async function getAndUpdateIndex(indexName, client) { index.fields.push({ type: "Edm.DateTimeOffset", name: "lastUpdatedOn", - filterable: true + filterable: true, }); await client.createOrUpdateIndex(index); } @@ -118,8 +119,9 @@ async function listIndexes(client) { console.log(`List of Indexes`); console.log(`***************`); while (!listOfIndexes.done) { + const { similarity } = listOfIndexes.value; console.log(`Name: ${listOfIndexes.value.name}`); - console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); + console.log(`Similarity Algorithm: ${similarity && similarity.odatatype}`); console.log(); listOfIndexes = await result.next(); } diff --git a/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js b/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js index 30f8c3b6aef5..a5f3ac9a7f16 100644 --- a/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js +++ b/sdk/search/search-documents/samples/v11/javascript/indexerOperations.js @@ -6,6 +6,7 @@ */ const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); + const dotenv = require("dotenv"); dotenv.config(); @@ -23,7 +24,7 @@ async function createIndexer(indexerName, client) { description: "Description for Sample Indexer", dataSourceName, targetIndexName, - isDisabled: false + isDisabled: false, }; await client.createIndexer(indexer); } @@ -56,21 +57,22 @@ async function listIndexers(client) { console.log(`\tList of Indexers`); console.log(`\t****************`); - for (let indexer of listOfIndexers) { + for (const indexer of listOfIndexers) { + const { schedule, parameters } = indexer; 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(`\tInterval: ${schedule && schedule.interval}`); + console.log(`\tStart Time: ${schedule && 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(`\tBatch Size: ${parameters && parameters.batchSize}`); + console.log(`\tMax Failed Items: ${parameters && parameters.maxFailedItems}`); + console.log(`\tMax Failed Items Per Batch: ${parameters && parameters.maxFailedItemsPerBatch}`); console.log(); } } diff --git a/sdk/search/search-documents/samples/v11/javascript/interfaces.js b/sdk/search/search-documents/samples/v11/javascript/interfaces.js deleted file mode 100644 index cb0ff5c3b541..000000000000 --- a/sdk/search/search-documents/samples/v11/javascript/interfaces.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/sdk/search/search-documents/samples/v11/javascript/package.json b/sdk/search/search-documents/samples/v11/javascript/package.json index cfe45076c457..0e3aa8de3db1 100644 --- a/sdk/search/search-documents/samples/v11/javascript/package.json +++ b/sdk/search/search-documents/samples/v11/javascript/package.json @@ -23,7 +23,6 @@ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents", "dependencies": { "@azure/search-documents": "next", - "dotenv": "latest", - "@azure/core-http": "^2.0.0" + "dotenv": "latest" } } diff --git a/sdk/search/search-documents/samples/v11/javascript/setup.js b/sdk/search/search-documents/samples/v11/javascript/setup.js index 1a14dec50b1b..fd289a71d925 100644 --- a/sdk/search/search-documents/samples/v11/javascript/setup.js +++ b/sdk/search/search-documents/samples/v11/javascript/setup.js @@ -2,19 +2,28 @@ // Licensed under the MIT license. /** - * @summary Defines the utility methods. + * Defines the utility methods. */ const { KnownAnalyzerNames } = require("@azure/search-documents"); -export const WAIT_TIME = 4000; +const WAIT_TIME = 4000; -export const documentKeyRetriever = (document) => { +const documentKeyRetriever = (document) => { return document.hotelId; }; +/** + * A wrapper for setTimeout that resolves a promise after timeInMs milliseconds. + * @param timeInMs - The number of milliseconds to be delayed. + * @returns Promise that is resolved after timeInMs + */ +function delay(timeInMs) { + return new Promise((resolve) => setTimeout(resolve, timeInMs)); +} + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters -export async function createIndex(client, name) { +async function createIndex(client, name) { const hotelIndex = { name, fields: [ @@ -23,26 +32,26 @@ export async function createIndex(client, name) { name: "hotelId", key: true, filterable: true, - sortable: true + sortable: true, }, { type: "Edm.String", name: "hotelName", searchable: true, filterable: true, - sortable: true + sortable: true, }, { type: "Edm.String", name: "description", searchable: true, - analyzerName: KnownAnalyzerNames.EnLucene + analyzerName: KnownAnalyzerNames.EnLucene, }, { type: "Edm.String", name: "descriptionFr", searchable: true, - analyzerName: KnownAnalyzerNames.FrLucene + analyzerName: KnownAnalyzerNames.FrLucene, }, { type: "Edm.String", @@ -50,48 +59,48 @@ export async function createIndex(client, name) { searchable: true, filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Collection(Edm.String)", name: "tags", searchable: true, filterable: true, - facetable: true + facetable: true, }, { type: "Edm.Boolean", name: "parkingIncluded", filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.Boolean", name: "smokingAllowed", filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.DateTimeOffset", name: "lastRenovationDate", filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.Double", name: "rating", filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.GeographyPoint", name: "location", filterable: true, - sortable: true + sortable: true, }, { type: "Edm.ComplexType", @@ -100,7 +109,7 @@ export async function createIndex(client, name) { { type: "Edm.String", name: "streetAddress", - searchable: true + searchable: true, }, { type: "Edm.String", @@ -108,7 +117,7 @@ export async function createIndex(client, name) { searchable: true, filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.String", @@ -116,7 +125,7 @@ export async function createIndex(client, name) { searchable: true, filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.String", @@ -124,7 +133,7 @@ export async function createIndex(client, name) { searchable: true, filterable: true, sortable: true, - facetable: true + facetable: true, }, { type: "Edm.String", @@ -132,9 +141,9 @@ export async function createIndex(client, name) { searchable: true, filterable: true, sortable: true, - facetable: true - } - ] + facetable: true, + }, + ], }, { type: "Collection(Edm.ComplexType)", @@ -144,62 +153,62 @@ export async function createIndex(client, name) { type: "Edm.String", name: "description", searchable: true, - analyzerName: KnownAnalyzerNames.EnLucene + analyzerName: KnownAnalyzerNames.EnLucene, }, { type: "Edm.String", name: "descriptionFr", searchable: true, - analyzerName: KnownAnalyzerNames.FrLucene + analyzerName: KnownAnalyzerNames.FrLucene, }, { type: "Edm.String", name: "type", searchable: true, filterable: true, - facetable: true + facetable: true, }, { type: "Edm.Double", name: "baseRate", filterable: true, - facetable: true + facetable: true, }, { type: "Edm.String", name: "bedOptions", searchable: true, filterable: true, - facetable: true + facetable: true, }, { type: "Edm.Int32", name: "sleepsCount", filterable: true, - facetable: true + facetable: true, }, { type: "Edm.Boolean", name: "smokingAllowed", filterable: true, - facetable: true + facetable: true, }, { type: "Collection(Edm.String)", name: "tags", searchable: true, filterable: true, - facetable: true - } - ] - } + facetable: true, + }, + ], + }, ], suggesters: [ { name: "sg", sourceFields: ["description", "hotelName"], - searchMode: "analyzingInfixMatching" - } + searchMode: "analyzingInfixMatching", + }, ], scoringProfiles: [ { @@ -212,16 +221,18 @@ export async function createIndex(client, name) { boost: 2, parameters: { referencePointParameter: "myloc", - boostingDistance: 100 - } - } - ] - } + boostingDistance: 100, + }, + }, + ], + }, ], corsOptions: { // for browser tests - allowedOrigins: ["*"] - } + allowedOrigins: ["*"], + }, }; await client.createIndex(hotelIndex); } + +module.exports = { WAIT_TIME, documentKeyRetriever, delay, createIndex }; diff --git a/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js b/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js index 7dac52d6209a..47abf5f099e8 100644 --- a/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js +++ b/sdk/search/search-documents/samples/v11/javascript/skillSetOperations.js @@ -6,6 +6,7 @@ */ const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents"); + const dotenv = require("dotenv"); dotenv.config(); @@ -25,29 +26,29 @@ async function createSkillset(skillsetName, client) { inputs: [ { name: "text", - source: "/document/merged_content" + source: "/document/merged_content", }, { name: "languageCode", - source: "/document/language" - } + source: "/document/language", + }, ], outputs: [ { name: "persons", - targetName: "people" + targetName: "people", }, { name: "organizations", - targetName: "organizations" + targetName: "organizations", }, { name: "locations", - targetName: "locations" - } - ] - } - ] + targetName: "locations", + }, + ], + }, + ], }; await client.createSkillset(skillset); } @@ -59,12 +60,12 @@ async function getAndUpdateSkillset(skillsetName, client) { skillset.skills[0].outputs = [ { name: "persons", - targetName: "people" + targetName: "people", }, { name: "organizations", - targetName: "organizations" - } + targetName: "organizations", + }, ]; await client.createOrUpdateSkillset(skillset); diff --git a/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js b/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js index 461dfe2bc434..b642e7f20340 100644 --- a/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js +++ b/sdk/search/search-documents/samples/v11/javascript/synonymMapOperations.js @@ -6,6 +6,7 @@ */ const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents"); + const dotenv = require("dotenv"); dotenv.config(); @@ -17,7 +18,7 @@ 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"] + synonyms: ["United States, United States of America => USA", "Washington, Wash. => WA"], }; await client.createSynonymMap(sm); } diff --git a/sdk/search/search-documents/samples/v11/typescript/README.md b/sdk/search/search-documents/samples/v11/typescript/README.md index 3bbd24fcda64..2bc1a4572837 100644 --- a/sdk/search/search-documents/samples/v11/typescript/README.md +++ b/sdk/search/search-documents/samples/v11/typescript/README.md @@ -21,8 +21,6 @@ These sample programs show how to use the TypeScript client libraries for Azure | [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. | @@ -84,8 +82,6 @@ Take a look at our [API Documentation][apiref] for more information about the AP [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 diff --git a/sdk/search/search-documents/samples/v11/typescript/package.json b/sdk/search/search-documents/samples/v11/typescript/package.json index 051120eea061..d5fb94a6e775 100644 --- a/sdk/search/search-documents/samples/v11/typescript/package.json +++ b/sdk/search/search-documents/samples/v11/typescript/package.json @@ -27,11 +27,10 @@ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents", "dependencies": { "@azure/search-documents": "next", - "dotenv": "latest", - "@azure/core-http": "^2.0.0" + "dotenv": "latest" }, "devDependencies": { - "typescript": "~4.2.0", + "typescript": "~4.4.0", "rimraf": "latest" } } diff --git a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts index 8363c1c1d994..b54381521708 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushSize.ts @@ -12,9 +12,9 @@ import { GeographyPoint, SearchIndexClient } from "@azure/search-documents"; -import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup"; import { Hotel } from "./interfaces"; -import { delay } from "@azure/core-http"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts index 4317f76ef564..c9a1f2391291 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderAutoFlushTimer.ts @@ -13,9 +13,9 @@ import { SearchIndexClient, DEFAULT_FLUSH_WINDOW } from "@azure/search-documents"; -import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup"; import { Hotel } from "./interfaces"; -import { delay } from "@azure/core-http"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts index 995e45b236ef..c289c4d6c957 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/bufferedSenderManualFlush.ts @@ -12,9 +12,9 @@ import { GeographyPoint, SearchIndexClient } from "@azure/search-documents"; -import { createIndex, documentKeyRetriever, WAIT_TIME } from "./setup"; +import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup"; import { Hotel } from "./interfaces"; -import { delay } from "@azure/core-http"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts index 20724b110293..8b0416617bc1 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/dataSourceConnectionOperations.ts @@ -10,6 +10,7 @@ import { AzureKeyCredential, SearchIndexerDataSourceConnection } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts index 89aec8a8ef65..4c1c8905cce6 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/indexOperations.ts @@ -11,6 +11,7 @@ import { SearchIndex, SearchIndexStatistics } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); @@ -123,8 +124,9 @@ async function listIndexes(client: SearchIndexClient) { console.log(`List of Indexes`); console.log(`***************`); while (!listOfIndexes.done) { + const { similarity } = listOfIndexes.value; console.log(`Name: ${listOfIndexes.value.name}`); - console.log(`Similarity Algorithm: ${listOfIndexes.value.similarity?.odatatype}`); + console.log(`Similarity Algorithm: ${similarity && similarity.odatatype}`); console.log(); listOfIndexes = await result.next(); } diff --git a/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts index f1530883c886..52b41fcd9ee4 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/indexerOperations.ts @@ -11,6 +11,7 @@ import { SearchIndexer, SearchIndexerStatus } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); @@ -61,21 +62,22 @@ async function listIndexers(client: SearchIndexerClient) { console.log(`\tList of Indexers`); console.log(`\t****************`); - for (let indexer of listOfIndexers) { + for (const indexer of listOfIndexers) { + const { schedule, parameters } = indexer; 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(`\tInterval: ${schedule && schedule.interval}`); + console.log(`\tStart Time: ${schedule && 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(`\tBatch Size: ${parameters && parameters.batchSize}`); + console.log(`\tMax Failed Items: ${parameters && parameters.maxFailedItems}`); + console.log(`\tMax Failed Items Per Batch: ${parameters && parameters.maxFailedItemsPerBatch}`); console.log(); } } diff --git a/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts b/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts index 1230fa50a70c..59eddc828db8 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/interfaces.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. /** - * @summary Defines the Hotel Interface. + * Defines the Hotel Interface. */ import { GeographyPoint } from "@azure/search-documents"; diff --git a/sdk/search/search-documents/samples/v11/typescript/src/setup.ts b/sdk/search/search-documents/samples/v11/typescript/src/setup.ts index d5478f2d9863..f34a4fdd16b0 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/setup.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/setup.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. /** - * @summary Defines the utility methods. + * Defines the utility methods. */ import { SearchIndexClient, SearchIndex, KnownAnalyzerNames } from "@azure/search-documents"; @@ -14,6 +14,15 @@ export const documentKeyRetriever: (document: Hotel) => string = (document: Hote return document.hotelId; }; +/** + * A wrapper for setTimeout that resolves a promise after timeInMs milliseconds. + * @param timeInMs - The number of milliseconds to be delayed. + * @returns Promise that is resolved after timeInMs + */ +export function delay(timeInMs: number): Promise { + return new Promise((resolve) => setTimeout(resolve, timeInMs)); +} + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters export async function createIndex(client: SearchIndexClient, name: string): Promise { const hotelIndex: SearchIndex = { diff --git a/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts index 8bf587fde6ec..488b381c75ba 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/skillSetOperations.ts @@ -10,6 +10,7 @@ import { AzureKeyCredential, SearchIndexerSkillset } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts b/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts index bc3dcac96818..3609f20c8344 100644 --- a/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts +++ b/sdk/search/search-documents/samples/v11/typescript/src/synonymMapOperations.ts @@ -6,6 +6,7 @@ */ import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents"; + import * as dotenv from "dotenv"; dotenv.config();