Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a huge library and its documents don't have any metadata. They have only the name (FileLeafRef) filled (and FileRef -> file's path automatically filled).

I'm trying to update their metadata (columns) using webservices. To do that, I enter the FileRef to get the ID of the file, and then execute the webservice to update using the returned ID. But this is taking to long, due the big number of documents.

Then, I will create a new index based on the column FileRef, so it'll be faster.

Does anyone know how to create a new index based on an internal field (using powershell)?

Thanks,

Douglas

share|improve this question
add comment

1 Answer

I use the following function to add an index

Function AddIndex ()
    {
    Param ($list,$InternalFldName)

        try
            {
             Write-Host "Updating index for list: $list";

            $fldToIndex =$list.Fields.GetFieldByInternalName($InternalFldName);                                                 
            try
              {
                 $index= $list.FieldIndexes.Item($fldToIndex.Id)
                 Write-Host  "Field $fldToIndex is indexed." -ForegroundColor Yellow
              }
              catch
              {
                 $fldToIndex.Indexed = $true;    
                 $list.FieldIndexes.Add($fldToIndex);
                Write-Host "Field $fldToIndex is added to indexed columns."  -ForegroundColor Green 
               }
            }
        catch
            {
             $error[0]
            }
            Write-Host 
    }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.