I can manually set an index on a column in a large SharePoint list (10000+ items) but I'm not able to do it programmatically.
With (PnP) PowerShell I've tried:
# get context
$Context = Get-PnPContext
# set
$fieldtocheck.indexed = $true
$fieldtocheck.update()
$Context.ExecuteQuery()
The last part ($Context.ExecuteQuery()) fails on a large list.
I've also tried using graph:
$uri = "https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/contosesite:/lists/listguid/columns/columntobeindexed"
$json = @'
{
"indexed":"true"
}
'@
Invoke-MgGraphRequest -uri $uri -body $json -Method PATCH -ContentType "application/json"
which also fails with: The request is unprocessable because it uses too many resources.
Is there a way without doing it manually by setting an index on a colummn in a large list? Thanks in advance.