You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/search/search-get-started-javascript.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,29 +32,29 @@ Before you begin, have the following tools and services:
32
32
33
33
+ An Azure Cognitive Search service. [Create a service](search-create-service-portal.md) or [find an existing service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices). You can use a free service for this quickstart.
34
34
35
-
+[Node.js](https://nodejs.org) and [NPM](https://www.npmjs.com)
35
+
+[Node.js](https://nodejs.org) and [npm](https://www.npmjs.com)
36
36
37
37
+[Visual Studio Code](https://code.visualstudio.com) or another IDE
38
38
39
39
## Set up your project
40
40
41
-
Start by getting the endpoint and key for your search service. Then create a new project with NPM as outlined below.
41
+
Start by getting the endpoint and key for your search service. Then create a new project with npm as outlined below.
42
42
43
43
<aname="get-service-info"></a>
44
44
45
45
### Copy a key and endpoint
46
46
47
-
Calls to the service require a URL endpoint and an access key on every request. As a first step, find the API key and URL to add to your project. You will specify both values when creating the client in a later step.
47
+
Calls to the service require a URL endpoint and an access key on every request. As a first step, find the API key and URL to add to your project. You'll specify both values when creating the client in a later step.
48
48
49
49
1.[Sign in to the Azure portal](https://portal.azure.com/), and in your search service **Overview** page, get the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
50
50
51
-
2. In **Settings** > **Keys**, get an admin key for full rights on the service, required if you are creating or deleting objects. There are two interchangeable primary and secondary keys. You can use either one.
51
+
2. In **Settings** > **Keys**, get an admin key for full rights on the service, required if you're creating or deleting objects. There are two interchangeable primary and secondary keys. You can use either one.
52
52
53
53

54
54
55
55
All requests require an api-key on every request sent to your service. Having a valid key establishes trust, on a per request basis, between the application sending the request and the service that handles it.
56
56
57
-
### Create a new NPM project
57
+
### Create a new npm project
58
58
59
59
Begin by opening VS Code and its [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal) or another terminal such as the Node.js command prompt.
60
60
@@ -65,7 +65,7 @@ Begin by opening VS Code and its [integrated terminal](https://code.visualstudio
65
65
cd quickstart
66
66
```
67
67
68
-
2. Initialize an empty project with NPM by running the following command. To fully initialize the project, press Enter multiple times to accept the default values, except for the License, which you should set to "MIT".
68
+
2. Initialize an empty project with npm by running the following command. To fully initialize the project, press Enter multiple times to accept the default values, except for the License, which you should set to "MIT".
69
69
70
70
```cmd
71
71
npm init
@@ -163,7 +163,7 @@ With that in place, we're ready to create an index.
163
163
164
164
Create a file **hotels_quickstart_index.json**. This file defines how Azure Cognitive Search works with the documents you'll be loading in the next step. Each field will be identified by a `name` and have a specified `type`. Each field also has a series of index attributes that specify whether Azure Cognitive Search can search, filter, sort, and facet upon the field. Most of the fields are simple data types, but some, like `AddressType` are complex types that allow you to create rich data structures in your index. You can read more about [supported data types](/rest/api/searchservice/supported-data-types) and index attributes described in [Create Index (REST)](/rest/api/searchservice/create-index).
165
165
166
-
Add the following to **hotels_quickstart_index.json** or [download the file](https://github.com/Azure-Samples/azure-search-javascript-samples/blob/master/quickstart/v11/hotels_quickstart_index.json).
166
+
Add the following content to **hotels_quickstart_index.json** or [download the file](https://github.com/Azure-Samples/azure-search-javascript-samples/blob/master/quickstart/v11/hotels_quickstart_index.json).
167
167
168
168
```json
169
169
{
@@ -309,7 +309,7 @@ Within the main function, we then create a `SearchIndexClient`, which is used to
Next, we want to delete the index if it already exists. This is a common practice for test/demo code.
312
+
Next, we want to delete the index if it already exists. This operation is a common practice for test/demo code.
313
313
314
314
We do this by defining a simple function that tries to delete the index.
315
315
@@ -354,7 +354,7 @@ If you [downloaded the source code](https://github.com/Azure-Samples/azure-searc
354
354
355
355
You should see a series of messages describing the actions being taken by the program.
356
356
357
-
Open the **Overview** of your search service in the Azure portal. Select the **Indexes** tab. You should see something like the following:
357
+
Open the **Overview** of your search service in the Azure portal. Select the **Indexes** tab. You should see something like the following example:
358
358
359
359
:::image type="content" source="media/search-get-started-javascript/create-index-no-data.png" alt-text="Screenshot of Azure portal, search service Overview, Indexes tab" border="false":::
360
360
@@ -502,7 +502,7 @@ The queries are written in a `sendQueries()` function that we'll call in the mai
502
502
awaitsendQueries(searchClient);
503
503
```
504
504
505
-
Queries are sent using the `search()` method of `searchClient`. The first parameter is the search text and the second parameter is any additional search options.
505
+
Queries are sent using the `search()` method of `searchClient`. The first parameter is the search text and the second parameter specifies search options.
506
506
507
507
The first query searches `*`, which is equivalent to searching everything and selects three of the fields in the index. It's a best practice to only `select` the fields you need because pulling back unnecessary data can add latency to your queries.
508
508
@@ -526,7 +526,7 @@ async function sendQueries(searchClient) {
526
526
}
527
527
```
528
528
529
-
The remaining queries outlined below should also be added to the `sendQueries()` function. They are separated here for readability.
529
+
The remaining queries outlined below should also be added to the `sendQueries()` function. They're separated here for readability.
530
530
531
531
In the next query, we specify the search term `"wifi"` and also include a filter to only return results where the state is equal to `'FL'`. Results are also ordered by the Hotel's `Rating`.
532
532
@@ -545,7 +545,7 @@ for await (const result of searchResults.results) {
545
545
}
546
546
```
547
547
548
-
Next, the search is limited to a single searchable field using the `searchFields` parameter. This is a great option to make your query more efficient if you know you're only interested in matches in certain fields.
548
+
Next, the search is limited to a single searchable field using the `searchFields` parameter. This approach is a great option to make your query more efficient if you know you're only interested in matches in certain fields.
549
549
550
550
```javascript
551
551
console.log('Query #3 - Limit searchFields:');
@@ -595,7 +595,7 @@ When you're working in your own subscription, it's a good idea at the end of a p
595
595
596
596
You can find and manage resources in the portal, using the **All resources** or **Resource groups** link in the left-navigation pane.
597
597
598
-
If you are using a free service, remember that you are limited to three indexes, indexers, and data sources. You can delete individual items in the portal to stay under the limit.
598
+
If you're using a free service, remember the limit of three indexes, indexers, and data sources. You can delete individual items in the portal to stay under the limit.
0 commit comments