如何为具有 $oid 唯一标识符类型的嵌入文档创建 Azure 认知搜索索引?

发布于 2025-01-16 10:41:58 字数 1366 浏览 3 评论 0原文

我当前的数据结构是这样的,

"customer": {
        "_id": {
            "$oid": "623a4b1bdb6d0a1210fd0234"
        },
        "customerName": "Andrew Jr"
    },

我需要为上述数据结构创建 ACS(Azure 认知搜索)。所以我使用了这样的东西:

{
        "name": "customer",
        "type": "Edm.ComplexType", 
        "fields": 
        [
            {
            "name": "customerName",
            "type": "Edm.String",
            "searchable": true, 
            "filterable": true, 
            "sortable": true, 
            "facetable": true
            }
        ]
     },

但是当我将 _id 添加为字符串数据类型时,它会向我抛出错误,例如,如下:

{
        "name": "customer",
        "type": "Edm.ComplexType", 
        "fields": 
        [
            {
                "name": "_id",
                "type": "Edm.String",
                "searchable": true, 
                "filterable": true, 
                "sortable": true, 
                "facetable": true
                },
            {
            "name": "customerName",
            "type": "Edm.String",
            "searchable": true, 
            "filterable": true, 
            "sortable": true, 
            "facetable": true
            }
        ]
     },

有什么想法如何将以下格式添加到搜索中吗?

 "_id": {
        "$oid": "623a4b1bdb6d0a1210fd0234"
    },

谢谢,

My current data structure is something like this,

"customer": {
        "_id": {
            "$oid": "623a4b1bdb6d0a1210fd0234"
        },
        "customerName": "Andrew Jr"
    },

I will need to create ACS (Azure Cognitive Search for the above data structure. So I was using something like this:

{
        "name": "customer",
        "type": "Edm.ComplexType", 
        "fields": 
        [
            {
            "name": "customerName",
            "type": "Edm.String",
            "searchable": true, 
            "filterable": true, 
            "sortable": true, 
            "facetable": true
            }
        ]
     },

But it will throw errors to me when I add the _id as a string data type, for example, below:

{
        "name": "customer",
        "type": "Edm.ComplexType", 
        "fields": 
        [
            {
                "name": "_id",
                "type": "Edm.String",
                "searchable": true, 
                "filterable": true, 
                "sortable": true, 
                "facetable": true
                },
            {
            "name": "customerName",
            "type": "Edm.String",
            "searchable": true, 
            "filterable": true, 
            "sortable": true, 
            "facetable": true
            }
        ]
     },

Any ideas how to add the following format to the search?

 "_id": {
        "$oid": "623a4b1bdb6d0a1210fd0234"
    },

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

檐上三寸雪 2025-01-23 10:41:58

您收到错误的原因很可能是字段名称无效 (_id)。

基于定义的命名规则 此处,字段名称只能包含字母、数字、下划线(“_”),但字段名称的第一个字符必须是字母。

由于您将字段命名为 _id,因此您将收到错误。

Most likely you are getting the error is because of invalid name for the field (_id).

Based on the naming rules defined here, a field name can only contain letters, numbers, underscores ("_") however the first character of the field name must be a letter.

Since you are naming your field as _id, you will get an error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文