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-howto-connecting-azure-sql-database-to-azure-search-using-indexers.md
+41-35Lines changed: 41 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,9 @@ Incremental indexing is possible. If you have a large data set and plan to run t
29
29
30
30
## Define the data source
31
31
32
-
1. Create the data source:
32
+
The data source definition specifies the data to index, credentials, and policies for identifying changes in the data. A data source is defined as an independent resource so that it can be used by multiple indexers.
33
+
34
+
1.[Create or update a data source](/rest/api/searchservice/create-data-source) to set its definition:
33
35
34
36
```http
35
37
POST https://myservice.search.windows.net/datasources?api-version=2020-06-30
@@ -44,9 +46,15 @@ Incremental indexing is possible. If you have a large data set and plan to run t
44
46
}
45
47
```
46
48
47
-
The connection string can follow either of the below formats:
48
-
1. You can get the connection string from the [Azure portal](https://portal.azure.com); use the `ADO.NET connection string` option.
49
-
1. A managed identity connection string that does not include an account key with the following format: `Initial Catalog|Database=<your database name>;ResourceId=/subscriptions/<your subscription ID>/resourceGroups/<your resource group name>/providers/Microsoft.Sql/servers/<your SQL Server name>/;Connection Timeout=connection timeout length;`. To use this connection string, follow the instructions for [Setting up an indexer connection to an Azure SQL Database using a managed identity](search-howto-managed-identities-sql.md).
49
+
1. Set "type" to `"azuresql"` (required).
50
+
51
+
1. Set "credentials" to a connection string:
52
+
53
+
+ You can get the connection string from the [Azure portal](https://portal.azure.com). Use the `ADO.NET connection string` option.
54
+
55
+
+ You can specify a managed identity connection string that does not include database secrets with the following format: `Initial Catalog|Database=<your database name>;ResourceId=/subscriptions/<your subscription ID>/resourceGroups/<your resource group name>/providers/Microsoft.Sql/servers/<your SQL Server name>/;Connection Timeout=connection timeout length;`.
56
+
57
+
To use this connection string, follow the instructions for [Setting up an indexer connection to an Azure SQL Database using a managed identity](search-howto-managed-identities-sql.md).
50
58
51
59
## Add search fields to an index
52
60
@@ -200,34 +208,33 @@ Within an indexer definition, you can specify a change detection policies that t
200
208
201
209
### SQL Integrated Change Tracking Policy
202
210
203
-
We recommend using **SQL Integrated Change Tracking Policy** for its efficiency and its ability to identify deleted rows.
211
+
We recommend using "SqlIntegratedChangeTrackingPolicy" for its efficiency and its ability to identify deleted rows.
204
212
205
-
#### Requirements
213
+
Database requirements:
206
214
207
-
+ Database version requirements:
208
-
* SQL Server 2012 SP3 and later, if you're using SQL Server on Azure VMs.
209
-
* Azure SQL Database or SQL Managed Instance.
210
-
+ Tables only (no views).
211
-
+ On the database, [enable change tracking](/sql/relational-databases/track-changes/enable-and-disable-change-tracking-sql-server) for the table.
212
-
+ No composite primary key (a primary key containing more than one column) on the table.
215
+
+ SQL Server 2012 SP3 and later, if you're using SQL Server on Azure VMs
216
+
+ Azure SQL Database or SQL Managed Instance
217
+
+ Tables only (no views).
218
+
+ On the database, [enable change tracking](/sql/relational-databases/track-changes/enable-and-disable-change-tracking-sql-server) for the table
219
+
+ No composite primary key (a primary key containing more than one column) on the table
213
220
214
-
#### Usage
215
-
216
-
To use this policy, create or update your data source like this:
221
+
Change detection policies are added to data source definitions. To use this policy, create or update your data source like this:
217
222
218
223
```http
224
+
POST https://myservice.search.windows.net/datasources?api-version=2020-06-30
When using SQL integrated change tracking policy, do not specify a separate data deletion detection policy - this policy has built-in support for identifying deleted rows. However, for the deletes to be detected "automagically", the document key in your search index must be the same as the primary key in the SQL table.
237
+
When using SQL integrated change tracking policy, do not specify a separate data deletion detection policy. The SQL integrated change tracking policy has built-in support for identifying deleted rows. However, for the deletes to be detected automatically, the document key in your search index must be the same as the primary key in the SQL table.
231
238
232
239
> [!NOTE]
233
240
> When using [TRUNCATE TABLE](/sql/t-sql/statements/truncate-table-transact-sql) to remove a large number of rows from a SQL table, the indexer needs to be [reset](/rest/api/searchservice/reset-indexer) to reset the change tracking state to pick up row deletions.
@@ -236,39 +243,38 @@ When using SQL integrated change tracking policy, do not specify a separate data
236
243
237
244
### High Water Mark Change Detection policy
238
245
239
-
This change detection policy relies on a "high water mark" column capturing the version or time when a row was last updated. If you're using a view, you must use a high water mark policy. The high water mark column must meet the following requirements.
246
+
This change detection policy relies on a "high water mark" column in your table or view that captures the version or time when a row was last updated. If you're using a view, you must use a high water mark policy.
240
247
241
-
#### Requirements
248
+
The high water mark column must meet the following requirements:
242
249
243
-
* All inserts specify a value for the column.
244
-
* All updates to an item also change the value of the column.
245
-
* The value of this column increases with each insert or update.
246
-
* Queries with the following WHERE and ORDER BY clauses can be executed efficiently: `WHERE [High Water Mark Column] > [Current High Water Mark Value] ORDER BY [High Water Mark Column]`
250
+
+ All inserts specify a value for the column.
251
+
+ All updates to an item also change the value of the column.
252
+
+ The value of this column increases with each insert or update.
253
+
+ Queries with the following WHERE and ORDER BY clauses can be executed efficiently: `WHERE [High Water Mark Column] > [Current High Water Mark Value] ORDER BY [High Water Mark Column]`
247
254
248
-
> [!IMPORTANT]
255
+
> [!NOTE]
249
256
> We strongly recommend using the [rowversion](/sql/t-sql/data-types/rowversion-transact-sql) data type for the high water mark column. If any other data type is used, change tracking is not guaranteed to capture all changes in the presence of transactions executing concurrently with an indexer query. When using **rowversion** in a configuration with read-only replicas, you must point the indexer at the primary replica. Only a primary replica can be used for data sync scenarios.
250
257
251
-
#### Usage
252
-
253
-
To use a high water mark policy, create or update your data source like this:
258
+
Change detection policies are added to data source definitions. To use this policy, create or update your data source like this:
254
259
255
260
```http
261
+
POST https://myservice.search.windows.net/datasources?api-version=2020-06-30
"highWaterMarkColumnName" : "[a rowversion or last_updated column name]"
272
+
}
265
273
}
266
274
```
267
275
268
-
> [!WARNING]
276
+
> [!NOTE]
269
277
> If the source table does not have an index on the high water mark column, queries used by the SQL indexer may time out. In particular, the `ORDER BY [High Water Mark Column]` clause requires an index to run efficiently when the table contains many rows.
0 commit comments