Node doesn't support some samples for smoke test (#18496)

* Node doesn't support some samples for smoke test

* [search-documents] reprocessed samples with exp. generator

Co-authored-by: Will Temple <will@wtemple.net>
This commit is contained in:
Sarangan Rajamanickam 2021-11-12 17:45:32 -08:00 коммит произвёл GitHub
Родитель 64480adb89
Коммит dc47dcb205
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
35 изменённых файлов: 173 добавлений и 137 удалений

Просмотреть файл

@ -141,7 +141,6 @@
],
"requiredResources": {
"Azure Search Documents instance": "https://docs.microsoft.com/azure/search/search-create-service-portal"
},
"skipFolder": true
}
}
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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();

Просмотреть файл

@ -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();

Просмотреть файл

@ -10,6 +10,7 @@ import {
AzureKeyCredential,
SearchIndexerDataSourceConnection
} from "@azure/search-documents";
import * as dotenv from "dotenv";
dotenv.config();

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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();
}
}

Просмотреть файл

@ -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";

Просмотреть файл

@ -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<void> {
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

Просмотреть файл

@ -10,6 +10,7 @@ import {
AzureKeyCredential,
SearchIndexerSkillset
} from "@azure/search-documents";
import * as dotenv from "dotenv";
dotenv.config();

Просмотреть файл

@ -6,6 +6,7 @@
*/
import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents";
import * as dotenv from "dotenv";
dotenv.config();

Просмотреть файл

@ -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

Просмотреть файл

@ -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) => {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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();
}
}

Просмотреть файл

@ -1 +0,0 @@
export {};

Просмотреть файл

@ -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"
}
}

Просмотреть файл

@ -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 };

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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"
}
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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();

Просмотреть файл

@ -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();

Просмотреть файл

@ -10,6 +10,7 @@ import {
AzureKeyCredential,
SearchIndexerDataSourceConnection
} from "@azure/search-documents";
import * as dotenv from "dotenv";
dotenv.config();

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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();
}
}

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT license.
/**
* @summary Defines the Hotel Interface.
* Defines the Hotel Interface.
*/
import { GeographyPoint } from "@azure/search-documents";

Просмотреть файл

@ -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<void> {
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<void> {
const hotelIndex: SearchIndex = {

Просмотреть файл

@ -10,6 +10,7 @@ import {
AzureKeyCredential,
SearchIndexerSkillset
} from "@azure/search-documents";
import * as dotenv from "dotenv";
dotenv.config();

Просмотреть файл

@ -6,6 +6,7 @@
*/
import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents";
import * as dotenv from "dotenv";
dotenv.config();