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
+51-19Lines changed: 51 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ This article supplements [**Create an indexer**](search-howto-create-indexers.md
19
19
20
20
## Prerequisites
21
21
22
-
+ An [Azure SQL database](../azure-sql/database/sql-database-paas-overview.md) with data in a single table or view. Use a table if you want the ability to [index data updates](#CaptureChangedRows) using SQL's native change detection capabilities.
22
+
+ An [Azure SQL database](../azure-sql/database/sql-database-paas-overview.md) with data in a single table or view. Use a table if you want the ability to [index incremental updates](#CaptureChangedRows) using SQL's native change detection capabilities.
23
23
24
24
+ Read permissions. Azure Cognitive Search supports SQL Server authentication, where the user name and password are provided on the connection string. Alternatively, you can [set up a managed identity and use Azure roles](search-howto-managed-identities-sql.md) to omit credentials on the connection.
25
25
@@ -50,7 +50,56 @@ Incremental indexing is possible. If you have a large data set and plan to run t
50
50
51
51
## Add search fields to an index
52
52
53
-
Create the target Azure Cognitive Search index if you don’t have one already. You can create an index using the [portal](https://portal.azure.com) or the [Create Index API](/rest/api/searchservice/Create-Index). Ensure that the schema of your target index is compatible with the schema of the source table - see [mapping between SQL and Azure Cognitive search data types](#TypeMapping).
53
+
In a [search index](search-what-is-an-index.md), add fields to accept values from corresponding fields in the SQL database. Ensure that the search index schema is compatible with source schema, with [equivalent data types](#TypeMapping).
54
+
55
+
1.[Create or update an index](/rest/api/searchservice/create-index) to define search fields that will store data:
56
+
57
+
```http
58
+
POST https://[service name].search.windows.net/indexes?api-version=2020-06-30
59
+
Content-Type: application/json
60
+
api-key: [Search service admin key]
61
+
{
62
+
"name": "mysearchindex",
63
+
"fields": [{
64
+
"name": "id",
65
+
"type": "Edm.String",
66
+
"key": true,
67
+
"searchable": false
68
+
},
69
+
{
70
+
"name": "description",
71
+
"type": "Edm.String",
72
+
"filterable": false,
73
+
"searchable": true,
74
+
"sortable": false,
75
+
"facetable": false,
76
+
"suggestions": true
77
+
}
78
+
]
79
+
}
80
+
```
81
+
82
+
1. Create a document key field ("key": true) that uniquely identifies each search document. This is the only field that's required. Typically, the table's primary key is mapped to the index key field. The document key must be unique and non-null. The values can be numeric in source data, but in a search index, a key is always a string.
83
+
84
+
1. Create additional fields for more searchable content. See [Create an index](search-how-to-create-search-index.md) for details.
85
+
86
+
<a name="TypeMapping"></a>
87
+
88
+
### Mapping data types
89
+
90
+
| SQL data type | Cognitive Search field types | Notes |
| smallmoney, money decimal numeric |Edm.String |Azure Cognitive Search does not support converting decimal types into Edm.Double because this would lose precision |
97
+
| char, nchar, varchar, nvarchar |Edm.String<br/>Collection(Edm.String) |A SQL string can be used to populate a Collection(Edm.String) field if the string represents a JSON array of strings: `["red", "white", "blue"]` |
@@ -298,23 +347,6 @@ The **softDeleteMarkerValue** must be a string in the JSON representation of you
298
347
299
348
If you are setting up a soft delete policy from the Azure portal, don't add quotes around the soft delete marker value. The field contents are already understood as a string and will be translated automatically into a JSON string for you. In the examples above, simply type `1`, `True` or `true` into the portal's field.
300
349
301
-
<aname="TypeMapping"></a>
302
-
303
-
## Mapping between SQL and Azure Cognitive Search data types
304
-
| SQL data type | Allowed target index field types | Notes |
| smallmoney, money decimal numeric |Edm.String |Azure Cognitive Search does not support converting decimal types into Edm.Double because this would lose precision |
311
-
| char, nchar, varchar, nvarchar |Edm.String<br/>Collection(Edm.String) |A SQL string can be used to populate a Collection(Edm.String) field if the string represents a JSON array of strings: `["red", "white", "blue"]`|
0 commit comments