Skip to content

Commit 0395e9b

Browse files
committed
field mapping refresh
1 parent cb28cb2 commit 0395e9b

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

articles/search/search-indexer-field-mappings.md

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ ms.author: heidist
1010
ms.service: cognitive-search
1111
ms.custom:
1212
- ignite-2023
13-
ms.topic: conceptual
14-
ms.date: 06/25/2024
13+
ms.topic: how-to
14+
ms.date: 07/29/2024
1515
---
1616

1717
# Field mappings and transformations using Azure AI Search indexers
@@ -24,7 +24,9 @@ Field mappings can also be used for light-weight data conversions, such as encod
2424

2525
Field mappings apply to:
2626

27-
+ Physical data structures on both sides of the data stream (between fields in a [supported data source](search-indexer-overview.md#supported-data-sources) and fields in a [search index](search-what-is-an-index.md)). If you're importing skill-enriched content that resides in memory, use [outputFieldMappings](cognitive-search-output-field-mapping.md) to map in-memory nodes to output fields in a search index.
27+
+ Physical data structures on both sides of the data stream (between fields in a [supported data source](search-indexer-overview.md#supported-data-sources) and fields in a [search index](search-what-is-an-index.md)).
28+
29+
If you're importing skill-generated content that resides in memory, use [outputFieldMappings](cognitive-search-output-field-mapping.md) to map in-memory nodes to output fields in a search index.
2830

2931
+ Search indexes only. If you're populating a [knowledge store](knowledge-store-concept-intro.md), use [projections](knowledge-store-projections-examples.md) for data path configuration.
3032

@@ -45,17 +47,37 @@ Field mappings apply to:
4547

4648
## Define a field mapping
4749

48-
Field mappings are added to the `fieldMappings` array of an indexer definition. A field mapping consists of three parts.
50+
This section explains how to set up field mappings.
4951

50-
```json
51-
"fieldMappings": [
52-
{
53-
"sourceFieldName": "_city",
54-
"targetFieldName": "city",
55-
"mappingFunction": null
56-
}
57-
]
58-
```
52+
### [**REST APIs**](#tab/rest)
53+
54+
1. Use [Create Indexer](/rest/api/searchservice/indexers/create) or [Create or Update Indexer](/rest/api/searchservice/indexers/create-or-update) or an equivalent method in an Azure SDK. Here's an example of an indexer definition.
55+
56+
```json
57+
{
58+
"name": "myindexer",
59+
"description": null,
60+
"dataSourceName": "mydatasource",
61+
"targetIndexName": "myindex",
62+
"schedule": { },
63+
"parameters": { },
64+
"fieldMappings": [],
65+
"disabled": false,
66+
"encryptionKey": { }
67+
}
68+
```
69+
70+
1. Fill out the `fieldMappings` array to specify the mappings. A field mapping consists of three parts.
71+
72+
```json
73+
"fieldMappings": [
74+
{
75+
"sourceFieldName": "_city",
76+
"targetFieldName": "city",
77+
"mappingFunction": null
78+
}
79+
]
80+
```
5981

6082
| Property | Description |
6183
|----------|-------------|
@@ -70,13 +92,9 @@ Azure AI Search uses case-insensitive comparison to resolve the field and functi
7092
> [!NOTE]
7193
> If no field mappings are present, indexers assume data source fields should be mapped to index fields with the same name. Adding a field mapping overrides the default field mappings for the source and target field. Some indexers, such as the [blob storage indexer](search-howto-indexing-azure-blob-storage.md), add default field mappings for the index key field.
7294

73-
You can use the REST API or an Azure SDK to define field mappings.
74-
75-
### [**REST APIs**](#tab/rest)
76-
77-
Use [Create Indexer (REST)](/rest/api/searchservice/indexers/create) or [Update Indexer (REST)](/rest/api/searchservice/indexers/create-or-update), any API version.
95+
#### Example: Name or type discrepancy
7896

79-
This example handles a field name discrepancy.
97+
An explicit field mapping establishes a data path for cases where name and type aren't identical.
8098

8199
```JSON
82100
PUT https://[service name].search.windows.net/indexers/myindexer?api-version=[api-version]
@@ -89,6 +107,8 @@ api-key: [admin key]
89107
}
90108
```
91109

110+
#### Example: One-to-many or forked data paths
111+
92112
This example maps a single source field to multiple target fields ("one-to-many" mappings). You can "fork" a field, copying the same source field content to two different index fields that will be analyzed or attributed differently in the index.
93113

94114
```JSON
@@ -99,6 +119,8 @@ This example maps a single source field to multiple target fields ("one-to-many"
99119
]
100120
```
101121

122+
You can use a similar approach for [skills-generated content](cognitive-search-output-field-mapping.md).
123+
102124
### [**.NET SDK (C#)**](#tab/csharp)
103125

104126
In the Azure SDK for .NET, use the [FieldMapping](/dotnet/api/azure.search.documents.indexes.models.fieldmapping) class that provides `SourceFieldName` and `TargetFieldName` properties and an optional `MappingFunction` reference.
@@ -136,11 +158,11 @@ A field mapping function transforms the contents of a field before it's stored i
136158
+ [urlEncode](#urlEncodeFunction)
137159
+ [urlDecode](#urlDecodeFunction)
138160

139-
Note that these functions are exclusively supported for parent indexes at this time. They are not compatible with chunked index mapping, therefore, these functions can't be used for [index projections](index-projections-concept-intro.md).
161+
Note that these functions are exclusively supported for parent indexes at this time. They aren't compatible with chunked index mapping, therefore, these functions can't be used for [index projections](index-projections-concept-intro.md).
140162

141163
<a name="base64EncodeFunction"></a>
142164

143-
### base64Encode function
165+
### base64Encode function and examples
144166

145167
Performs *URL-safe* Base64 encoding of the input string. Assumes that the input is UTF-8 encoded.
146168

@@ -301,7 +323,7 @@ For example, if the input string is `["red", "white", "blue"]`, then the target
301323

302324
#### Example - populate collection from relational data
303325

304-
Azure SQL Database doesn't have a built-in data type that naturally maps to `Collection(Edm.String)` fields in Azure AI Search. To populate string collection fields, you can pre-process your source data as a JSON string array and then use the `jsonArrayToStringCollection` mapping function.
326+
Azure SQL Database doesn't have a built-in data type that naturally maps to `Collection(Edm.String)` fields in Azure AI Search. To populate string collection fields, you can preprocess your source data as a JSON string array and then use the `jsonArrayToStringCollection` mapping function.
305327

306328
```JSON
307329
"fieldMappings" : [

0 commit comments

Comments
 (0)