SharePoint Indexed Columns | Create Indexed Column in SharePoint List

Do you want to know about indexing in SharePoint or SharePoint indexed columns? Here, I will explain in detail, what are indexed columns in SharePoint. And, how to create an indexed column in a SharePoint list.

I also explain, what is an indexed column in SharePoint and the need to create an index column in the SharePoint list.

Also, I am going to explain the below points related to indexing in SharePoint online.

  • Create the indexed column automatically through the SharePoint list view filter
  • How to remove an index in SharePoint Online
  • Create an indexed column in SharePoint using PowerShell
  • Remove the indexed column from the SharePoint Online list using PowerShell
  • PnP PowerShell to create an index column in SharePoint Online

What is indexing in SharePoint?

SharePoint indexed columns improve speed in large lists when you often filter and query a column. In SharePoint Online, a special kind of column called an “Indexed column” helps to hold values that can be used as search keys.

You can add indexes to up to 20 columns on a SharePoint list or library.

Although you are allowed to add up to 20 indexes per list or library, it is suggested that you restrict the number of indexes you create to the most often used columns and those that you use to filter data both in views and by utilizing the column headers.

Supported and unsupported columns for SharePoint indexing

The table below represents all the supported and unsupported columns for indexing in SharePoint online.

Supported Column TypesUnsupported Column Types
Single line of textMultiple lines of text
Choice [single value]Choice [multi-valued]
NumberCalculated
CurrencyHyperlink or Picture
Date and TimeCustom Columns
Person or Group [Single value] [Lookup]Person or Group [multi-valued] [Lookup]
Managed metadata [Lookup]External data
Yes/No
Lookup [Lookup]

How to add indexed columns in SharePoint Online?

Next, we will see how to create or add an index column in SharePoint Online. There are two types of indexing columns in the SharePoint Online list:

  • Simple indexed column
  • Compound indexed column

Simple indexed column in SharePoint Online

To create a simple indexed column in the SharePoint list, follow the instructions below:

  • Go to specific SharePoint Online list/library -> Click on the Gear or Settings icon -> List settings.
indexing in sharepoint online
  • Under the Columns section, select Indexed columns as shown below.
what is indexing in sharepoint
  • On the Indexed Columns window, click on Create a new index.
SharePoint list indexing
  • Select a column from the Primary column for this index drop-down menu and click Create.
Create index in SharePoint list
  • Now, the indexed column has been created for the specific SharePoint list.
sharepoint indexed columns

This way, we can create a Simple index in the SharePoint Online list.

Compound-indexed column in SharePoint Online

We can also create a compound index in the SharePoint list.

  • To create a compound index in the SharePoint Online list, navigate to the same Create Index column page, and if you choose both Primary and Secondary columns for indexing, it becomes a compound index.
  • Only a few types of columns will be available for a secondary index, but not all columns are supported. The “Secondary Column” dropdown list’s enabled columns will be supported.
  • I have chosen the Primary and Secondary columns for the indexing in the image below. Click on Create.
what is an indexed column in sharepoint
  • In the SharePoint list, a compound index column will now be created, and the index column page will appear as follows:
what are indexed columns in sharepoint

This is how to create a compound-indexed column in SharePoint Online.

NOTE:

When your list reaches 5,000 items, the Auto-Indexing feature in SharePoint automatically generates the required indices.

Create an indexed column automatically through SharePoint list view filter

Any indexed allowed columns (specified in the section above) added to the SharePoint list view filter are automatically indexed. Let’s have a look at this.

  • Expand the All Items view in the SharePoint Online list -> Select Edit current view.
Create indexed column automatically through SharePoint list view filter
  • Then, from the Filter section, Select the column as Status Type is equal to Old Post Update. Now that we have applied a filter, the Status Type column will be seen on the “Indexed Column” page because it is automatically indexed.
indexing in sharepoint online
  • When you return to the specific SharePoint list, it will look like the image below.
indexing in sharepoint

This is how to create the indexed column automatically through the SharePoint list view filter.

How to remove an index in SharePoint Online

  • If you want to remove an existing index in the SharePoint Online List, open the Indexed Columns page and click the column you want to delete.
How to remove an index in SharePoint Online
  • Next, click on Delete.
Delete an index in SharePoint Online
  • Click on OK to delete else, click on Cancel.
indexed columns sharepoint

This is how to remove an index in the SharePoint Online list.

Create an indexed column in SharePoint using PowerShell

  • In my SharePoint online site, I have a list named Logging (custom list); if I check, no indexed column is associated with the list.
  • To check this, click the List Settings page and click on the Indexed columns link above the Views section. Then you can see there are no index columns like the screenshot below:
sharepoint indexed columns
  • Now, below is the PowerShell script to create the indexed column. Here, we are retrieving the list column and then setting the indexed column using the $field.Indexed = $true.
  • You can run and debug the PowerShell script by using Windows PowerShell ISE.
Add-Type -Path "E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$siteUrl = “https://onlysharepoint2013.sharepoint.com/sites/Bhawana/”
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$securePassword=ConvertTo-SecureString "*****" -AsPlainText -Force
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("bijay@onlysharepoint2013.onmicrosoft.com", $securePassword)
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
$list = $ctx.Web.Lists.GetByTitle('Logging')
$field = $list.Fields.GetByTitle('Title')
$field.Indexed = $true
$field.Update()
$ctx.ExecuteQuery()
  • Once you execute the above script, you can see it will create one indexed column as “Title” like below:
what is an indexed column in sharepoint

This way, we can create an indexed column in SharePoint using PowerShell.

Remove the indexed column from the SharePoint Online list using PowerShell

  • We can also easily remove indexed columns from the SharePoint online list using PowerShell. We can remove the indexed column we created above using the PowerShell script below.
Add-Type -Path "E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$siteUrl = “https://onlysharepoint2013.sharepoint.com/sites/Bhawana/”
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$securePassword=ConvertTo-SecureString "**********" -AsPlainText -Force
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(“bijay@onlysharepoint2013.onmicrosoft.com”, $securePassword)
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
$list = $ctx.Web.Lists.GetByTitle('Logging')
$field = $list.Fields.GetByTitle('Title')
$field.Indexed = $false
$field.Update()
$ctx.ExecuteQuery()
  • Once you run the above script, it will remove the indexed column from the list. You can see below:
indexed columns sharepoint

This way, we can remove the indexed column from the SharePoint Online list using PowerShell.

PnP PowerShell to create an index column in SharePoint Online

The PnP PowerShell code below helps you to create an index column in a SharePoint Online list or library.

#Config Variables
$SiteURL = "https://xyz.sharepoint.com"
$ListName = "Products"
$ColumnName = "ProductName"      #Internal Name
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
 
#Get the Context
$Context = Get-PnPContext
 
#Get the Field from List
$Field = Get-PnPField -List $ListName -Identity $ColumnName
 
#Set the Indexed Property of the Field
$Field.Indexed = $True
$Field.Update()
$Context.ExecuteQuery()

This is all about PnP PowerShell to create an index column in a SharePoint Online list.

Conclusion

I hope you got an idea of indexing in sharepoint, especially, what is an indexed column in SharePoint and how to create an index column in SharePoint Online.

Moreover, we saw what are the supported and unsupported columns for SharePoint indexing, how to add indexed columns in SharePoint Online, and many more like:

  • How to create the indexed column automatically through the SharePoint list view filter
  • Delete an index in SharePoint Online
  • Create an indexed column in SharePoint using PowerShell
  • How to delete an indexed column from the SharePoint Online list using PowerShell
  • PnP PowerShell to create an index column in SharePoint Online

I hope you can implement indexing in SharePoint online.

You may also like:

>