ARTICLE

How to delete a file type from the content index in SharePoint 2010

Posted by Vijai Anand Articles | SharePoint 2010 February 08, 2011
In this article we will be seeing how to delete a file type from the content index in SharePoint 2010.
Reader Level:

In this article we will be seeing how to delete a file type from the content index in SharePoint 2010.

Using Central Administration:

  • Go to Central Administration => Application Management => Manage Service Applications => Search Service Application.
  • In the navigation, go to Crawling => File Types.
  • Select the file type, click on ECB Menu => Delete.

    IndeShare1.gif

Using Visual Studio 2010:

  • Open Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application from the installed templates.
  • Enter the Name and click Ok.
  • Add the following references.

    o Microsoft.SharePoint.dll
    o Microsoft.Office.Server.dll
    o Microsoft.Office.Server.Search.dll
     
  • Add the following namespaces.

    o using Microsoft.Office.Server.Search.Administration;
    o using Microsoft.Office.Server;
    o using Microsoft.SharePoint;
     
  • Replace the code with the following.

     //  search service application name             
     string ssaName ="Search Service Application";
     SearchContext context =SearchContext.GetContext(ssaName);
     Content ssaContent =new Content(context);
    //  Get the list of file extensions            
     ExtensionCollection extensionColl = ssaContent.ExtensionList;
    //  Get the file extension
     Extension ext=extensionColl["ascx"];
    //  Delete the file extension            
     ext.Delete();

     foreach (Extension extensionin extensionColl)
     {
    //  Display the file extension name           
     
         Console.WriteLine(extension.FileExtension.ToString());
     }

     

  • Build the solution.
  • Hit F5.
  • File type of extension ascx is deleted and display all the file extensions as shown in the following.

    IndeShare2.gif

Using Powershell:

  • Run SharePoint 2010 Management Shell as an administrator.
  • Add the following script to create a new file type to the content index.

    $ssaName="Search Service Application"
    $context=[Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($ssaName)
    $ssaContent=New-Object Microsoft.Office.Server.Search.Administration.Content($context)
    $ssaContent.ExtensionList.Create("ascx")

    IndeShare3.gif
     

Login to add your contents and source code to this article
post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts