Skip to content

Commit ad8a7f3

Browse files
committed
Synched with article
1 parent a11d938 commit ad8a7f3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

quickstart/index.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
#!/usr/bin/env/node
2-
3-
const hotelData = require("hotels.json");
4-
const indexDefinition = require("hotels_quickstart_index.json");
5-
62
const nconf = require('nconf');
7-
const AzureSearchClient = require('./AzureSearchClient.js');
83

9-
function getAzureConfiguration() {
10-
const config = nconf.file({ file: 'azure_search_config.json' });
11-
if (config.get('serviceName') == '[SEARCH_SERVICE_NAME' || config.get('adminKey') == '[SEARCH_SERVICE_API_KEY]') {
12-
throw new Error("You have not set the values in your azure_search_config.json file. Please change them to match your search service's values.");
13-
}
14-
return config;
15-
}
4+
const hotelData = require('./hotels.json');
5+
const indexDefinition = require('./hotels_quickstart_index.json');
6+
const AzureSearchClient = require('./AzureSearchClient.js');
167

178
const queries = [
189
"*&$count=true",
1910
"historic&$filter=Rating gt 4&"
2011
];
2112

22-
13+
function getAzureConfiguration() {
14+
const config = nconf.file({ file: 'azure_search_config.json' });
15+
if (config.get('serviceName') === '[SEARCH_SERVICE_NAME') {
16+
throw new Error("You have not set the values in your azure_search_config.json file.Change them to match your search service's values.");
17+
}
18+
return config;
19+
}
2320

2421
function sleep(ms)
2522
{
@@ -50,7 +47,6 @@ const run = async () => {
5047
await exists ? client.deleteIndexAsync() : Promise.resolve();
5148
// Deleting index can take a few seconds
5249
await sleep(2000);
53-
const indexDefinition = require('./hotels_quickstart_index.json');
5450
await client.createIndexAsync(indexDefinition);
5551
// Index availability can take a few seconds
5652
await sleep(2000);

0 commit comments

Comments
 (0)