dis*_*sco 4 azure azure-cognitive-search azure-rm-template
有多种方法可以通过 ARM 模板创建 Azure 搜索服务(示例:https: //raw.githubusercontent.com/azure/azure-quickstart-templates/master/101-azure-search-create/azuredeploy.json)。
我想知道有没有办法在 ARM 模板中定义特定索引(字段、数据源、索引器等)?
我知道您可以使用 REST 服务来创建和修改索引,但我不希望在创建资源组和 Azure 搜索服务后使用单独的脚本/应用程序来处理该服务。
对唐的评论+1。您需要使用REST API或.NET SDK创建索引。如果您碰巧使用 PowerShell 创建服务,您可能会发现以下代码很有用,它使用 Invoke-RestMethod 和一组包含索引架构和一些文档的 .JSON 文件调用 REST API。
#------------------------#
# Setting up search index#
#------------------------#
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", 'application/json')
$headers.Add("api-key", $searchApiKey)
Write-Host
Write-Host "Creating Index..."
$schemaFile = "$(Split-Path $MyInvocation.MyCommand.Path)\zipcodes.schema"
$response = Invoke-RestMethod -TimeoutSec 10000 $searchServiceUrl"/indexes/zipcodes2?api-version=2015-02-28-Preview" -Method Put -Headers $headers -Body "$(get-content $schemaFile)"
Write-Host $response
$jsonFile = "$(Split-Path $MyInvocation.MyCommand.Path)\zipcodes1.json"
Write-Host
Write-Host "Adding Documents from $jsonFile..."
$response = Invoke-RestMethod -TimeoutSec 10000 $searchServiceUrl"/indexes/zipcodes2/docs/index?api-version=2015-02-28-Preview" -Method Post -Headers $headers -Body "$(get-content $jsonFile)"
Write-Host $response
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2221 次 |
| 最近记录: |