Azure AI Search uygulamalarınıza kurumsal düzeyde arama kapasitesi ekler. PowerShell ile index oluşturabilir, belge yükleyebilir ve arama sorgularını test edebilirsiniz.
Search Service Oluşturmak
PowerShell
New-AzSearchService -ResourceGroupName "newrg-" -Name "myaisearchonur" `
-Sku "Standard" -Location "uksouth" -PartitionCount 1 -ReplicaCount 1
$adminKey = (Get-AzSearchAdminKeyPair -ResourceGroupName "newrg-" -ServiceName "myaisearchonur").Primary
Write-Host "Search Service olusturuldu. Admin Key: $adminKey"

Index Oluşturmak
PowerShell
$endpoint = "https://myaisearchonur.search.windows.net"
$headers = @{ "api-key" = $adminKey; "Content-Type" = "application/json" }
$indexBody = @{
name = "articles-index"
fields = @(
@{ name = "id"; type = "Edm.String"; key = $true }
@{ name = "title"; type = "Edm.String"; searchable = $true }
@{ name = "content"; type = "Edm.String"; searchable = $true }
@{ name = "category"; type = "Edm.String"; filterable = $true }
)
} | ConvertTo-Json -Depth 5
Invoke-RestMethod -Uri "$endpoint/indexes/articles-index?api-version=2023-11-01" `
-Headers $headers -Method Put -Body $indexBody
Write-Host "Index olusturuldu." -ForegroundColor Green

Belge Yüklemek ve Arama Yapmak
PowerShell
$docs = @{ value = @(@{ "@search.action" = "upload"; id = "1"; title = "Azure AI ile PowerShell"; content = "Azure AI Foundry ve PowerShell ile denemeler yapmak by Baki Onur Okutucu – Microsoft MVP"; category = "Azure AI" }) } | ConvertTo-Json -Depth 5
Invoke-RestMethod -Uri "$endpoint/indexes/articles-index/docs/index?api-version=2023-11-01" `
-Headers $headers -Method Post -Body $docs
$results = Invoke-RestMethod -Uri "$endpoint/indexes/articles-index/docs?search=PowerShell&top=5&api-version=2023-11-01" `
-Headers $headers -Method Get
$results.value | Select-Object title, category | Format-Table
Write-Host "Arama tamamlandı. $($results.count) sonuç." -ForegroundColor Green
