如何在 Azure Search REST API 上使用 "id" 删除特定文档?

How to delete specific document using "id" on Azure Search REST API?

我想知道如何删除 Azure 搜索索引中的特定文档。

我想使用 "id" 通过 REST API 删除文档。我找过,没找到路

{
    "@odata.context": "https://xxxx/$metadata#docs(*)",
    "value": [
        {
            "@search.score": 1,
            "id": "16",
            "questions": [
                "Question"
            ],
            "answer": "Answer",
            "source": "https://azure.microsoft.com/ja-jp/support/faq/",
            "keywords": [],
            "alternateQuestions": null
 },

比如我只想删除id为16的文档,不想删除整个索引,只想删除文档

如果有人知道怎么做,请提供一个 REST API 示例。

有关如何在 Azure 搜索中删除 "documents" 的文档可以是 found here. 因为您想删除与 id == 16 关联的所有字段,所以这应该是您要查找的内容.

为了更具体地说明您的具体情况,您需要向以下 URI 发出 POST 请求,其中包含适当的服务名称、索引名称和 api 管理密钥(作为 header) 填写:

POST https://[service name].search.windows.net/indexes/[index name]/docs/index?api-version=2017-11-11  
Content-Type: application/json   
api-key: [admin key]  

并提出以下请求 body:

{  
  "value": [  
    {  
      "@search.action": "delete",  
      "id": "16"  
    }  
  ]  
}

如果请求returns 200,则文档将已成功从索引中删除。

请注意,您可以在同一请求中删除多个文档,方法是在 JSON 数组中包含更多 objects,每个文档具有不同的 "id"。这比一次删除一个更有效。