我使用 Azure 搜索索引器对 MongoDB CosmosDB 中的文档进行索引,该数据库包含带有名为 的字段的对象_id。由于 Azure 搜索不允许在索引中的字段名称开头使用下划线,因此我想创建字段映射。
Cosmos 中的 JSON 结构 --> 索引中的结构
{
"id": "test"
"name": "test",
"productLine": {
"_id": "123", --> "id": "123"
"name": "test"
}
}
Run Code Online (Sandbox Code Playgroud)
该文档正是以这种情况作为示例,但仅适用于顶级字段。
"fieldMappings" : [ { "sourceFieldName" : "_id", "targetFieldName" : "id" } ]}
我尝试了以下方法:
"fieldMappings" : [ { "sourceFieldName" : "productLine/_id", "targetFieldName" : "productLine/id" } ] }
这会导致错误:
Value is not accepted. Valid values: "doc_id", "name", "productName".
为作为子字段的目标字段创建映射的正确方法是什么?