Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sdk/search/search-documents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
],
"requiredResources": {
"Azure Search Documents instance": "https://docs.microsoft.com/azure/search/search-create-service-portal"
},
"skipFolder": true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
AzureKeyCredential,
SearchIndexerDataSourceConnection
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SearchIndex,
SearchIndexStatistics
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

Expand Down Expand Up @@ -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();
}
Expand Down
14 changes: 8 additions & 6 deletions sdk/search/search-documents/samples-dev/indexerOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SearchIndexer,
SearchIndexerStatus
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

Expand Down Expand Up @@ -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();
}
}
Expand Down
5 changes: 4 additions & 1 deletion sdk/search/search-documents/samples-dev/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 3 additions & 2 deletions sdk/search/search-documents/samples-dev/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
AzureKeyCredential,
SearchIndexerSkillset
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { SearchIndexClient, AzureKeyCredential, SynonymMap } from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -50,8 +50,8 @@ function getDocumentsArray(size) {
rating: 5,
location: new GeographyPoint({
longitude: -122.131577,
latitude: 47.678581
})
latitude: 47.678581,
}),
});
}
return array;
Expand All @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -83,9 +83,9 @@ async function main() {
rating: 5,
location: new GeographyPoint({
longitude: -122.131577,
latitude: 47.678581
})
}
latitude: 47.678581,
}),
},
]);

await bufferedClient.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

const { SearchIndexerClient, AzureKeyCredential } = require("@azure/search-documents");

const dotenv = require("dotenv");
dotenv.config();

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

const { SearchIndexClient, AzureKeyCredential } = require("@azure/search-documents");

const dotenv = require("dotenv");
dotenv.config();

Expand All @@ -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",
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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();
}
Expand Down
Loading