如何在Azure中搜索复杂的json对象(例如嵌套数组)中的字段映射 [英] How to do field mapping in azure search for complex json objects for example nested array

查看:62
本文介绍了如何在Azure中搜索复杂的json对象(例如嵌套数组)中的字段映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题我有一个字段映射更新到索引.有效载荷很复杂,其中我有:

I have following problem I have a field mapping update to an index .Payload is complex where I have:

{
    "type": "abc",
    "Party": [{
        "Type": "abc",
        "Id": "123",
        "Name": "manasa",
        "Phone": [{
            "Type": "Office",
            "Number": "12345"
        }]
    }]
}

现在我想为索引创建一个字段.字段名称是Collection(Edm.String)类型的电话号码映射在哪里

And now I want to create a field for an index. The field name is phonenumber of type Collection(Edm.String) where mapping is

{
"sourceFieldName" : "/Party/Phone/Number",
"targetFieldName" : "phonenumber",
"mappingFunction" : { "name" : "jsonArrayToStringCollection" }
}

在http帖子正文中但是仍然在索引后我将电话号码结果设为null.这意味着映射出错了.如果您在源json中看到电话号码,则它在json数组内,并且它本身是一个数组,结果需要存储在集合中字符串.有可能如何实现?如果无法做到这一点,我至少希望将字段映射到电话阵列,即/Party/Phone/

In http post body But still after indexing i get phone number result as null.That means the mapping went wrong.If you see the phone number in source json, it is inside a json array and it itself is an array and result needs to get stored inside a collection of a string.Is it possible how can I achieve this? If this is not possible I atleast want field mapping till phone array ie., /Party/Phone/

如果我将完整的聚会数组索引为文本,则在运行索引时出现错误:

If i index complete party array as a text, I get an error while running the index saying:

"Field 'partydetails' contains a term that is too large to process. The max length for UTF-8 encoded terms is 32766 bytes. The most likely cause of this error is that filtering, sorting, and/or faceting are enabled on this field, which causes the entire field value to be indexed as a single term. Please avoid the use of these options for large fields."

有人可以帮忙吗!

推荐答案

请注意,Party和Phone是数组,因此您提到的字段映射将不起作用.

Note that Party and Phone are arrays, so the field mapping you mention won't work.

您将需要索引到特定元素.例如:

You will need to index into the specific element. For example:

{
    "sourceFieldName": "/Party/0/Phone/0/Type",
    "targetFieldName": "firstPhoneNumberTypeOfFirstParty"
}

您可能想尝试一下.

谢谢!

路易斯·卡布雷拉|计划经理|Azure搜索

Luis Cabrera | Program Manager | Azure Search

这篇关于如何在Azure中搜索复杂的json对象(例如嵌套数组)中的字段映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆