I'm wondering if it's possible to add an Index to a column in every Item of a specific Content Type.

I'm still having issues with the List View Threshold in an Intranet Site Collection so that CQWP's are failing to return items for users.

I thought I might be able to apply the indexing once rather than for every List that uses the Content Type in question Event

Thoughts?

有帮助吗?

解决方案

Indexes are associated with List. So you need to modify the list and add index.

You can automate this using PowerShell.

$site = Get-SPsite http://siteurl 

foreach ($web in $site.AllWebs)  
{ 
    #foreach ($list in $web.Lists) 
    for ($i = 0; $i -lt $web.Lists.Count; $i++)
    {
        $list = $web.Lists[$i]
        foreach ($ct in $list.ContentTypes)  
        {  
            if ($ct.Name -eq "Your Content Type Name")  
            {  
                #Logic to create index 
                $field = $list.Fields["Field Name To Index"]
                $field.Indexed = $true
                $field.Update()
            } 
        } 
    }  
    $web.Dispose()  
} 
许可以下: CC-BY-SA归因
scroll top