How to add a file type to the content index in SharePoint 2010


In this article we will be seeing how to add a file type to 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.
  • Click on "New File Type".

    Share1.gif
     
  • Enter the file extension.

    Share2.gif
     
  • Click on Ok.
  • A new file type is added successfully.

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);
                //ExtensionList => Get the list of file name extensions
                ssaContent.ExtensionList.Create("ascx");

     
  • Build the solution.
  • Hit F5.
  • A new file type is added successfully.

    Share3.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")

    Share4.gif