如何在Azure搜索中解码编码数据?

时间:2016-08-02 06:47:05

标签: azure-search

我在我的Web API中使用Azure搜索进行搜索。 使用的索引器源:SQL Azure数据库 被索引的列具有特殊字符。因此,我在推入Azure搜索时对数据进行编码。

作为从Azure搜索检索的一部分,有没有办法解码数据?

我在Azure搜索中只能在线找到的文档是decoding metadata of blobs.

1 个答案:

答案 0 :(得分:0)

问题涉及使用可能包含键无效字符的表列作为文档键。 要使其工作,请定义字段映射并应用base64Encode函数。见https://azure.microsoft.com/en-us/documentation/articles/search-indexer-field-mappings/#base64EncodeFunction

请注意,Azure搜索会将编码值存储为文档的键。如果您确实想要搜索/过滤原始值,请在字段映射中分叉原始值,如下所示:

"fieldMappings" : [ 
  { "sourceFieldName" : "Id", "targetFieldName" : "Id", "mappingFunction" : { "name" : "base64Encode" } },
  { "sourceFieldName" : "Id", "targetFieldName" : "OriginalId" }
]

HTH!

相关问题