使用 VScode Azure 认知服务扩展,一次在索引中插入多个文档。 (Azure 搜索服务)

时间:2021-06-16 16:09:21

标签: azure azure-devops azure-cognitive-search

我想一次将多个文档插入到Azure Search Service中的索引中。我正在使用 VScode 扩展 Azure Cognitive Services 插入他们的文档中提到的内容。

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

官方文档提到了插入单个JSON的方法,即右键单击文档->创建新文档

我尝试使用上述方法插入以逗号分隔的多个 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 在索引中一次插入多个文档的方法吗?

1 个答案:

答案 0 :(得分:1)

您可以使用 Postman 来做同样的事情,方法是使用在正文中传递的 JSON 创建 POST 请求。这适用于进入索引的单个和多个文档。

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

相关问题