Skip to content

Commit 911db2f

Browse files
committed
Azure SQL create index section
1 parent 598bd99 commit 911db2f

File tree

1 file changed

+51
-19
lines changed

1 file changed

+51
-19
lines changed

articles/search/search-howto-connecting-azure-sql-database-to-azure-search-using-indexers.md

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This article supplements [**Create an indexer**](search-howto-create-indexers.md
1919

2020
## Prerequisites
2121

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.
2323

2424
+ 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.
2525

@@ -50,7 +50,56 @@ Incremental indexing is possible. If you have a large data set and plan to run t
5050

5151
## Add search fields to an index
5252

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 |
91+
| ------------- | -------------------------------- | --- |
92+
| bit |Edm.Boolean, Edm.String | |
93+
| int, smallint, tinyint |Edm.Int32, Edm.Int64, Edm.String | |
94+
| bigint |Edm.Int64, Edm.String | |
95+
| real, float |Edm.Double, Edm.String | |
96+
| 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"]` |
98+
| smalldatetime, datetime, datetime2, date, datetimeoffset |Edm.DateTimeOffset, Edm.String | |
99+
| uniqueidentifer |Edm.String | |
100+
| geography |Edm.GeographyPoint |Only geography instances of type POINT with SRID 4326 (which is the default) are supported |
101+
| rowversion |Not applicable |Row-version columns cannot be stored in the search index, but they can be used for change tracking |
102+
| time, timespan, binary, varbinary, image, xml, geometry, CLR types |N/A |Not supported |
54103
55104
## Configure and run the Azure SQL indexer
56105
@@ -298,23 +347,6 @@ The **softDeleteMarkerValue** must be a string in the JSON representation of you
298347

299348
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.
300349

301-
<a name="TypeMapping"></a>
302-
303-
## Mapping between SQL and Azure Cognitive Search data types
304-
| SQL data type | Allowed target index field types | Notes |
305-
| --- | --- | --- |
306-
| bit |Edm.Boolean, Edm.String | |
307-
| int, smallint, tinyint |Edm.Int32, Edm.Int64, Edm.String | |
308-
| bigint |Edm.Int64, Edm.String | |
309-
| real, float |Edm.Double, Edm.String | |
310-
| 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"]` |
312-
| smalldatetime, datetime, datetime2, date, datetimeoffset |Edm.DateTimeOffset, Edm.String | |
313-
| uniqueidentifer |Edm.String | |
314-
| geography |Edm.GeographyPoint |Only geography instances of type POINT with SRID 4326 (which is the default) are supported |
315-
| rowversion |N/A |Row-version columns cannot be stored in the search index, but they can be used for change tracking |
316-
| time, timespan, binary, varbinary, image, xml, geometry, CLR types |N/A |Not supported |
317-
318350
## Configuration Settings
319351
SQL indexer exposes several configuration settings:
320352

0 commit comments

Comments
 (0)