Skip to content

Commit

Permalink
Merge pull request #663 from wobba/re-index-caution
Browse files Browse the repository at this point in the history
Added text to highlight when this script is ok to run.
  • Loading branch information
pkbullock authored Feb 23, 2024
2 parents acb9ab7 + 446cbb6 commit 589a650
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
20 changes: 17 additions & 3 deletions scripts/spo-reindex-sites/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@
plugin: add-to-gallery
---

# Reindex SharePoint sites
# Re-index SharePoint sites

## Summary

Keeping your SharePoint environment up-to-date is crucial, especially after making schema changes. This PnP PowerShell script streamlines the process of reindexing sites, libraries, or lists to ensure that search results remain accurate and relevant.
When using SharePoint columns in search solutions, you may need to map crawled properties to managed properties and update the search schema. For example, you can map the crawled property `ows_Foo` to `RefinableString100` and use it as a filter in [KQL](https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference). For more information, refer to [How Do Site Columns Become Managed Properties](https://learn.microsoft.com/en-us/microsoft-365/community/how-do-site-columns-become-managed-properties-thus-available-for-search).

If your schema change applies to existing content, you must schedule a re-index operation for the affected content in order to have the data populated into the search index.

> [!IMPORTANT]
> Scheduling of re-indexing should **ALWAYS** happen at the smallest level possible. If affected data is in a specific library or list, then re-index ONLY the specific library. This can be achieved via the site settings in SharePoint or by using the command [Request-PnPReIndexList](https://pnp.github.io/powershell/cmdlets/Request-PnPReIndexList.html).
> [!CAUTION]
> The below script should **ONLY** be used for the scenario where a schema mapping affects ALL content in your tenant. Site re-indexing may add stress to the search system and take an extended amount of time to complete. Re-crawls of sites with more than one million items can potentially take weeks to process. Subsequent index updates could be delayed until the re-indexing is complete, leading to out-of-date search results. Make sure to only initiate a site re-index after making changes that require all items to be reindexed.
This PnP PowerShell script streamlines the process of re-indexing sites, libraries, or lists to ensure that search results remain accurate and relevant.

# [PnP PowerShell](#tab/pnpps)

```PowerShell
#Prompt for caution
Read-Host -Prompt "Are you sure you know what you are doing, and have read the text at https://pnp.github.io/script-samples/spo-reindex-sites/README.html?"
#Set Parameters
$AdminCenterURL="https://contoso-admin.sharepoint.com"
Connect-PnPOnline -Url $AdminCenterURL -Interactive
Expand All @@ -31,7 +44,8 @@ $m365Sites | ForEach-Object {
## Contributors
| Author(s) |
|-----------|
| [Reshmee Auckloo](https://github.com/reshmee011)|
| [Reshmee Auckloo (script)](https://github.com/reshmee011)|
| [Mikael Svenson (caution text)](https://github.com/wobba)|


[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
Expand Down
10 changes: 8 additions & 2 deletions scripts/spo-reindex-sites/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"title": "Reindex SharePoint sites",
"url": "https://pnp.github.io/script-samples/spo-reindex-sites/README.html",
"creationDateTime": "2024-02-19",
"updateDateTime": "2024-02-19",
"updateDateTime": "2024-02-23",
"shortDescription": "Keeping your SharePoint environment up-to-date is crucial, especially after making schema changes - this script streamlines the process of reindexing sites, libraries, or lists. ",
"longDescription": null,
"longDescription": ["The script should **ONLY** be used for the scenario where a schema mapping affects ALL content in your tenant. Site re-indexing may add stress to the search system and take an extended amount of time to complete. Re-crawls of sites with more than one million items can potentially take weeks to process. Subsequent index updates could be delayed until the re-indexing is complete, leading to out-of-date search results. Make sure to only initiate a site re-index after making changes that require all items to be reindexed."],
"products": [
"SharePoint"
],
Expand Down Expand Up @@ -37,6 +37,12 @@
}
],
"authors": [
{
"gitHubAccount": "wobba",
"company": "",
"pictureUrl": "https://github.com/wobba.png",
"name": "Mikael Svenson"
},
{
"gitHubAccount": "reshmee011",
"company": "",
Expand Down

0 comments on commit 589a650

Please sign in to comment.