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/tutorial-multiple-data-sources.md
+26-31Lines changed: 26 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ author: HeidiSteen
8
8
ms.author: heidist
9
9
ms.service: cognitive-search
10
10
ms.topic: conceptual
11
-
ms.date: 11/04/2019
11
+
ms.date: 12/23/2019
12
12
---
13
13
14
14
# C# Tutorial: Combine data from multiple data sources in one Azure Cognitive Search index
@@ -34,15 +34,15 @@ The following services, tools, and data are used in this quickstart.
34
34
35
35
-[Create an Azure Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/create-cosmosdb-resources-portal) for storing the sample hotel data.
36
36
37
-
-[Create an Azure storage account](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account) for storing the sample JSON blob data.
37
+
-[Create an Azure storage account](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account) for storing the sample room data.
38
38
39
-
-[Install Visual Studio](https://visualstudio.microsoft.com/) to use as the IDE.
39
+
-[Install Visual Studio 2019](https://visualstudio.microsoft.com/) to use as the IDE.
40
40
41
41
### Install the project from GitHub
42
42
43
43
1. Locate the sample repository on GitHub: [azure-search-dotnet-samples](https://github.com/Azure-Samples/azure-search-dotnet-samples).
44
44
1. Select **Clone or download** and make your private local copy of the repository.
45
-
1. Open Visual Studio and install the Microsoft Azure Cognitive Search NuGet package, if not already installed. In the **Tools** menu, select **NuGet Package Manager** and then **Manage NuGet Packages for Solution...**. In the **Browse** tab, find and then install **Microsoft.Azure.Search** (version 9.0.1, or later). You will have to click through additional dialogs to complete the installation.
45
+
1. Open Visual Studio 2019 and install the Microsoft Azure Cognitive Search NuGet package, if not already installed. In the **Tools** menu, select **NuGet Package Manager** and then **Manage NuGet Packages for Solution...**. In the **Browse** tab, find and then install **Microsoft.Azure.Search** (version 9.0.1, or later). You will have to click through additional dialogs to complete the installation.
46
46
47
47

48
48
@@ -52,7 +52,7 @@ The following services, tools, and data are used in this quickstart.
52
52
53
53
To interact with your Azure Cognitive Search service, you need the service URL and an access key. 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:
54
54
55
-
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`.
55
+
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`.
56
56
57
57
1. In **Settings** > **Keys**, get an admin key for full rights on the service. There are two interchangeable admin keys, provided for business continuity in case you need to roll one over. You can use either the primary or secondary key on requests for adding, modifying, and deleting objects.
58
58
@@ -64,35 +64,35 @@ All requests require an api-key on every request sent to your service. A valid k
64
64
65
65
This sample uses two small sets of data that describe seven fictional hotels. One set describes the hotels themselves, and will be loaded into an Azure Cosmos DB database. The other set contains hotel room details, and is provided as seven separate JSON files to be uploaded into Azure Blob Storage.
66
66
67
-
1.[Sign in to the Azure portal](https://portal.azure.com), and then navigate your Azure Cosmos DB account Overview page.
67
+
1. Sign in to the [Azure portal](https://portal.azure.com), and then navigate your Azure Cosmos DB account Overview page.
68
68
69
-
1.From the menu bar, click Add Container. Specify "Create new database" and use the name **hotel-rooms-db**. Enter **hotels** for the collection name, and **/HotelId** for the Partition key. Click **OK** to create the database and container.
69
+
1.Select **Data Explorer** and then select **New Database**.
70
70
71
-

71
+

72
72
73
-
1.Go to the Cosmos DB Data Explorer and select the **items** element under the **hotels** container within the **hotel-rooms-db** database. Then click **Upload Item** on the command bar.
73
+
1.Enter the name **hotel-rooms-db**. Accept default values for the remaining settings.
74
74
75
-

1. Create a new container. Use the existing database you just created. Enter **hotels** for the container name, and use **/HotelId** for the Partition key.
76
78
77
-
1. In the upload panel, click the folder button and then navigate to the file **cosmosdb/HotelsDataSubset_CosmosDb.json** in the project folder. Click **OK** to start the upload.

81
+
1. Select **Items** under **hotels**, and then click **Upload Item** on the command bar. Navigate to and then select the file **cosmosdb/HotelsDataSubset_CosmosDb.json** in the project folder.
82
+
83
+

80
84
81
85
1. Use the Refresh button to refresh your view of the items in the hotels collection. You should see seven new database documents listed.
82
86
83
87
## Prepare sample blob data
84
88
85
-
1.[Sign in to the Azure portal](https://portal.azure.com), navigate to your Azure storage account, click **Blobs**, and then click **+ Container**.
89
+
1. Sign in to the [Azure portal](https://portal.azure.com), navigate to your Azure storage account, click **Blobs**, and then click **+ Container**.
86
90
87
91
1.[Create a blob container](https://docs.microsoft.com/azure/storage/blobs/storage-quickstart-blobs-portal) named **hotel-rooms** to store the sample hotel room JSON files. You can set the Public Access Level to any of its valid values.
88
92
89
93

90
94
91
-
1. After the container is created, open it and select **Upload** on the command bar.
92
-
93
-

94
-
95
-
1. Navigate to the folder containing the sample files. Select all of them and then click **Upload**.
95
+
1. After the container is created, open it and select **Upload** on the command bar. Navigate to the folder containing the sample files. Select all of them and then click **Upload**.
@@ -125,11 +125,11 @@ The next entries specify account names and connection string information for the
125
125
126
126
In Azure Cognitive Search, the key field uniquely identifies each document in the index. Every search index must have exactly one key field of type `Edm.String`. That key field must be present for each document in a data source that is added to the index. (In fact, it's the only required field.)
127
127
128
-
When indexing data from multiple data sources, each data source key value must map to the same key field in the combined index. It often requires some up-front planning to identify a meaningful document key for your index, and make sure it exists in every data source.
128
+
When indexing data from multiple data sources, use a common document key to merge data from two physically distinct source documents into a new search document in the combined index. It often requires some up-front planning to identify a meaningful document key for your index, and make sure it exists in both data sources. In this demo, the HotelId key for each hotel in Cosmos DB is also present in the rooms JSON blobs in Blob storage.
129
129
130
130
Azure Cognitive Search indexers can use field mappings to rename and even reformat data fields during the indexing process, so that source data can be directed to the correct index field.
131
131
132
-
For example, in our sample Azure Cosmos DB data, the hotel identifier is called **HotelId**. But in the JSON blob files for the hotel rooms, the hotel identifier is named **Id**. The program handles this by mapping the **Id** field from the blobs to the **HotelId** key field in the index.
132
+
For example, in our sample Azure Cosmos DB data, the hotel identifier is called **`HotelId`**. But in the JSON blob files for the hotel rooms, the hotel identifier is named **`Id`**. The program handles this by mapping the **`Id`** field from the blobs to the **`HotelId`** key field in the index.
133
133
134
134
> [!NOTE]
135
135
> In most cases auto-generated document keys, such as those created by default by some indexers, do not make good document keys for combined indexes. In general you will want to use a meaningful, unique key value that already exists in, or can be easily added to, your data sources.
@@ -139,11 +139,11 @@ For example, in our sample Azure Cosmos DB data, the hotel identifier is called
139
139
Once the data and configuration settings are in place, the sample program in **AzureSearchMultipleDataSources.sln** should be ready to build and run.
140
140
141
141
This simple C#/.NET console app performs the following tasks:
142
-
* Creates a new Azure Cognitive Search index based on the data structure of the C# Hotel class (which also references the Address and Room classes).
143
-
* Creates an Azure Cosmos DB data source and an indexer that maps Azure Cosmos DB data to index fields.
144
-
* Runs the Azure Cosmos DB indexer to load Hotel data.
145
-
* Creates an Azure Blob Storage data source and an indexer that maps JSON blob data to index fields.
146
-
* Runs the Azure blob storage indexer to load Rooms data.
142
+
* Creates a new index based on the data structure of the C# Hotel class (which also references the Address and Room classes).
143
+
* Creates a new data source and an indexer that maps Azure Cosmos DB data to index fields. These are both objects in Azure Cognitive Search.
144
+
* Runs the indexer to load Hotel data from Cosmos DB.
145
+
* Creates a second data source and an indexer that maps JSON blob data to index fields.
146
+
* Runs the second indexer to load Rooms data from Blob storage.
147
147
148
148
Before running the program, take a minute to study the code and the index and indexer definitions for this sample. The relevant code is in two files:
149
149
@@ -296,7 +296,7 @@ After the data source is created, the program sets up a blob indexer named **hot
0 commit comments