Skip to content

Commit ddc9cf7

Browse files
authored
Merge pull request #105525 from HeidiSteen/heidist-master
[Azure Cognitive Search] Freshness pass over Node.js quickstart
2 parents 2d43cec + 015d75c commit ddc9cf7

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

articles/search/search-get-started-java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2727

2828
## Prerequisites
2929

30-
We used the following software and services to build and test this sample:
30+
We used the following software and services to build and test this quickstart:
3131

3232
+ [IntelliJ IDEA](https://www.jetbrains.com/idea/)
3333

articles/search/search-get-started-nodejs.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.author: heidist
99
ms.devlang: nodejs
1010
ms.service: cognitive-search
1111
ms.topic: quickstart
12-
ms.date: 11/04/2019
12+
ms.date: 02/25/2020
1313
---
1414
# Quickstart: Create an Azure Cognitive Search index in Node.js using REST APIs
1515
> [!div class="op_single_selector"]
@@ -20,25 +20,30 @@ ms.date: 11/04/2019
2020
> * [Python](search-get-started-python.md)
2121
> * [Postman](search-get-started-postman.md)
2222
23-
Create a Node.js application that that creates, loads, and queries an Azure Cognitive Search index. This article demonstrates how to create the application step-by-step. Alternately, you can [download the source code and data](https://github.com/Azure-Samples/azure-search-javascript-samples/tree/master/quickstart/) and run the application from the command line.
23+
Create a Node.js application that that creates, loads, and queries an Azure Cognitive Search index. This article demonstrates how to create the application step-by-step. Alternatively, you can [download the source code and data](https://github.com/Azure-Samples/azure-search-javascript-samples/tree/master/quickstart/) and run the application from the command line.
2424

2525
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2626

2727
## Prerequisites
2828

29-
The following services, tools, and data are used in this quickstart.
29+
We used the following software and services to build and test this quickstart:
30+
31+
+ [Node.js](https://nodejs.org)
32+
33+
+ [NPM](https://www.npmjs.com) should be installed by Node.js
34+
35+
+ A sample index structure and matching documents are provided in this article, or from the [**quickstart** directory of the repo](https://github.com/Azure-Samples/azure-search-javascript-samples/)
3036

31-
+ [Node.js](https://nodejs.org).
32-
+ [NPM](https://www.npmjs.com) should be installed by Node.js.
33-
+ A sample index structure and matching documents are provided in this article, or from the [**quickstart** directory of the repo](https://github.com/Azure-Samples/azure-search-javascript-samples/).
3437
+ [Create an Azure Cognitive Search service](search-create-service-portal.md) or [find an existing service](https://ms.portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices) under your current subscription. You can use a free service for this quickstart.
3538

3639
Recommended:
3740

38-
* [Visual Studio Code](https://code.visualstudio.com).
41+
* [Visual Studio Code](https://code.visualstudio.com)
42+
3943
* [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) and [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extensions for VSCode.
4044

4145
<a name="get-service-info"></a>
46+
4247
## Get keys and URLs
4348

4449
Calls to the service require a URL endpoint and an access key on every request. A search service is created with both, so if you added Azure Cognitive Search to your subscription, follow these steps to get the necessary information:
@@ -103,16 +108,17 @@ Begin by opening a Powershell console or other environment in which you've insta
103108
}
104109
}
105110
```
106-
Create a file **azure_search_config.json** to hold your search service data:
107111
108-
```json
109-
{
110-
"serviceName" : "[SERVICE_NAME]",
111-
"adminKey" : "[ADMIN_KEY]",
112-
"queryKey" : "[QUERY_KEY]",
113-
"indexName" : "hotels-quickstart"
114-
}
115-
```
112+
5. Create a file **azure_search_config.json** to hold your search service data:
113+
114+
```json
115+
{
116+
"serviceName" : "[SEARCH_SERVICE_NAME]",
117+
"adminKey" : "[ADMIN_KEY]",
118+
"queryKey" : "[QUERY_KEY]",
119+
"indexName" : "hotels-quickstart"
120+
}
121+
```
116122
117123
Replace the `[SERVICE_NAME]` value with the name of your search service. Replace `[ADMIN_KEY]` and `[QUERY_KEY]` with the key values you recorded earlier.
118124
@@ -398,7 +404,7 @@ The [**nconf** package](https://github.com/indexzero/nconf) allows you to specif
398404
```javascript
399405
function getAzureConfiguration() {
400406
const config = nconf.file({ file: 'azure_search_config.json' });
401-
if (config.get('serviceName') === '[SEARCH_SERVICE_NAME' ) {
407+
if (config.get('serviceName') === '[SEARCH_SERVICE_NAME]' ) {
402408
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.");
403409
}
404410
return config;
@@ -428,7 +434,7 @@ Finally, specify and call the main asynchronous `run` function. This function ca
428434
const run = async () => {
429435
try {
430436
const cfg = getAzureConfiguration();
431-
const client = new AzureSearchClient(cfg.get("serviceName"), cfg.get("adminKey"), cfg.get("queryKey"), cfg.get["serviceName"]);
437+
const client = new AzureSearchClient(cfg.get("serviceName"), cfg.get("adminKey"), cfg.get("queryKey"), cfg.get("indexName));
432438
433439
const exists = await client.indexExistsAsync();
434440
await exists ? client.deleteIndexAsync() : Promise.resolve();

0 commit comments

Comments
 (0)