Skip to content

Commit a66b94c

Browse files
committed
Updated the Field Mappings article. Added a .NET SDK section. Simplfied other examples. Edited, and fixed typos.
1 parent 34dd7b0 commit a66b94c

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

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

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Some situations where field mappings are useful:
2525
* You need to Base64 encode or decode your data. Field mappings support several **mapping functions**, including functions for Base64 encoding and decoding.
2626

2727
> [!NOTE]
28-
> The field mapping feature of Azure Search indexers provides a simple way to map data fields to index fields, with a few options for data conversion. More complex data might require pre-processing to transform it into a form that's easy to index.
28+
> The field mapping feature of Azure Search indexers provides a simple way to map data fields to index fields, with a few options for data conversion. More complex data might require pre-processing to reshape it into a form that's easy to index.
2929
>
3030
> Microsoft Azure Data Factory is a powerful cloud-based solution for importing and transforming data. You can also write code to transform source data before indexing. For code examples, see [Model relational data](search-example-adventureworks-modeling.md) and [Model multilevel facets](search-example-adventureworks-multilevel-faceting.md).
3131
>
@@ -118,21 +118,9 @@ Performs *URL-safe* Base64 encoding of the input string. Assumes that the input
118118

119119
#### Example - document key lookup
120120

121-
Only URL-safe characters can appear in an Azure Search document key (because customers must be able to address the document using the [Lookup API](https://docs.microsoft.com/rest/api/searchservice/lookup-document) ). If your data contains URL-unsafe characters and you want to use it to populate a key field in your search index, use this function. Once the key is encoded, you can use base64 decode to retrieve the original value. For details, see the [base64 encoding and decoding](#base64details) section.
121+
Only URL-safe characters can appear in an Azure Search document key (because customers must be able to address the document using the [Lookup API](https://docs.microsoft.com/rest/api/searchservice/lookup-document) ). If the source field for your key contains URL-unsafe characters, you can use the `base64Encode` function to convert it at indexing time.
122122

123-
```JSON
124-
125-
"fieldMappings" : [
126-
{
127-
"sourceFieldName" : "SourceKey",
128-
"targetFieldName" : "IndexKey",
129-
"mappingFunction" : { "name" : "base64Encode" }
130-
}]
131-
```
132-
133-
#### Example - retrieve original key
134-
135-
You have a blob indexer that indexes blobs with the blob path metadata as the document key. After retrieving the encoded document key, you want to decode the path and download the blob.
123+
When you retrieve the encoded key at search time, you can then use the `base64Decode` function to get the original key value, and use that to retrieve the source document.
136124

137125
```JSON
138126

@@ -147,17 +135,19 @@ You have a blob indexer that indexes blobs with the blob path metadata as the do
147135
}]
148136
```
149137

150-
If you don't need to look up documents by keys and also don't need to decode the encoded content, you can just leave out `parameters` for the mapping function, which defaults `useHttpServerUtilityUrlTokenEncode` to `true`. Otherwise, see [base64 details](#base64details) section to decide which settings to use.
138+
If you don't include a parameters property for your mapping function, it defaults to the value `{"useHttpServerUtilityUrlTokenEncode" : true}`.
139+
140+
Azure Search supports two different Base64 encodings. You should use the same parameters when encoding and decoding the same field. For more details, see [base64 encoding options](#base64details) to decide which parameters to use.
151141

152142
<a name="base64DecodeFunction"></a>
153143

154144
### base64Decode function
155145

156146
Performs Base64 decoding of the input string. The input is assumed to be a *URL-safe* Base64-encoded string.
157147

158-
#### Example - decode blob metadata
148+
#### Example - decode blob metadata or URLs
159149

160-
Blob custom metadata values must be ASCII-encoded. You can use Base64 encoding to represent arbitrary UTF-8 strings in blob custom metadata. To make search data more meaningful, you can use the base64Decode function to turn the encoded data back into regular strings when populating your search index.
150+
Your source data might contain contains Base64-encoded strings, such as blob metadata strings or web URLs, that you want to make searchable as plain text. You can use the `base64Decode` function to turn the encoded data back into regular strings when populating your search index.
161151

162152
```JSON
163153

@@ -172,11 +162,13 @@ Blob custom metadata values must be ASCII-encoded. You can use Base64 encoding t
172162
}]
173163
```
174164

175-
If you don't specify any `parameters`, then the default value of `useHttpServerUtilityUrlTokenDecode` is `true`. See the [base64 encoding options](#base64details) section to decide which settings to use.
165+
If you don't include a parameters property, it defaults to the value `{"useHttpServerUtilityUrlTokenEncode" : true}`.
166+
167+
Azure Search supports two different Base64 encodings. You should use the same parameters when encoding and decoding the same field. For more details, see [base64 encoding options](#base64details) to decide which parameters to use.
176168

177169
<a name="base64details"></a>
178170

179-
### base64 encoding options
171+
#### base64 encoding options
180172

181173
Azure Search supports two different Base64 encodings: **HttpServerUtility URL token**, and **URL-safe Base64 encoding without padding**. You must use the same encoding as the mapping functions to encode a document key for lookup, encode a value that will be decoded by the indexer, or decode a field that was encoded by the indexer.
182174

0 commit comments

Comments
 (0)