将 azure 搜索中的新字段设置为默认值

时间:2021-06-29 20:32:19

标签: azure-cognitive-search

我正在使用 Azure 搜索,当我添加一个新字段时,它会变为空。
有没有办法设置默认值?

PUT {{servicename}}/indexes/{{indexname}}?api-version=2019-05-06
Content-Type: application/json   
api-key: {{adminkey}}

{  
  "fields": [
    {  
      "name": "rid",
      "type": "Edm.String",
      "searchable": false,
      "filterable": false,
      "sortable": false,
      "facetable": false,
      "key": true
    },   
    {
      "name": "NewField",
      "type": "Edm.Boolean"
    }
}

搜索结果是

{
    "@odata.context": "https://whatever.search.windows.net/indexes('indexname')/$metadata#docs(*)",
    "value": [
        {
            "@search.score": 0.55735236,
            "rid": "asdfasdf",
            "Email": null
        }
    ]
}

1 个答案:

答案 0 :(得分:1)

<块引用>

有没有办法设置默认值?

基于documentation,没有。

enter image description here

添加新字段后,您必须手动 update 现有文档以设置该添加字段的值。如文档中所述,您可以使用 merge 作为 @search.action 仅更新新添加的字段。