首页 > 解决方案 > 使用 VScode Azure Cognitive Services 扩展一次在索引中插入多个文档。(Azure 搜索服务)

问题描述

我想一次将多个文档插入到Azure 搜索服务中的索引中。我正在使用 VScode 扩展Azure Cognitive Services插入,如他们的文档中所述。

链接到官方文档: https ://docs.microsoft.com/en-us/azure/search/search-get-started-vs-code

官方文档提到了插入单个 JSON 的方法,即Right Click Document->Create new document

我尝试使用上述方法插入多个用逗号分隔的 JSON 文档(如下所示),我得到了预期的错误:

Unexpected token, in JSON at position 915

我尝试在一个创建新文档中插入多个文档

{
"HotelId": "4",
"HotelName": "Sublime Cliff Hotel",
"Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.",
"Description_fr": null,
"Category": "Boutique",
"Tags": [
    "concierge",
    "view",
    "24-hour front desk service"
],
"ParkingIncluded": true,
"LastRenovationDate": "1960-02-06T00:00:00Z",
"Rating": 4.6,
"Address": {
    "StreetAddress": "7400 San Pedro Ave",
    "City": "San Antonio",
    "StateProvince": "TX",
    "PostalCode": "78216",
    "Country": "USA"
}
},
{
"HotelId": "5",
"HotelName": "Sublime Cliff Hotel",
"Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.",
"Description_fr": null,
"Category": "Boutique",
"Tags": [
    "concierge",
    "view",
    "24-hour front desk service"
],
"ParkingIncluded": true,
"LastRenovationDate": "1960-02-06T00:00:00Z",
"Rating": 4.6,
"Address": {
    "StreetAddress": "7400 San Pedro Ave",
    "City": "San Antonio",
    "StateProvince": "TX",
    "PostalCode": "78216",
    "Country": "USA"
}
}

有谁知道使用 VScode 在索引中一次插入多个文档的任何方法?

标签: azureazure-devopsazure-cognitive-search

解决方案


您可以使用Postman执行相同的操作,方法是使用在正文中传递的 JSON 创建一个 POST 请求。这适用于索引中的单个和多个文档条目。

官方文档链接 - https://docs.microsoft.com/en-us/azure/search/search-get-started-rest


推荐阅读