If you like my blog post please subscribe to my YouTube Channel “SYNK Ventures – Let’s talk about Microsoft 365” as well https://www.youtube.com/channel/UC6vLzWN-3aFG8dgTgEOlx5g?sub_confirmation=1
This a common error message which you can see if you have search issues “Object reference not to set an instance of an object”. This error message does not tell much and you will have to look SharePoint log and find the correlation ID.
If you search on the internet for this error you will hit numerous reasons and fix for it. Problem is that error message is very generic and can be seen for various kind of issues. I have encountered this in two scenarios which I am gonna list down.
First thing you need to check SharePoint health, if there is an error in that best resolution is to recreate the index
You must have some error message in SharePoint search status like below
If that is the not the case the other reason can be you have orphaned items in your farm / content database. Generally you will get error message in SharePoint Health Analyzer for this but in our case we did not get it strangely. So basically you cannot trust it so best is to look for correlation ID in SharePoint Log.
What I observed is that when you search in SharePoint it will enumerate all site collections and it might fail doing so if you have orphaned items. You should look carefully and find out which content database it was enumerating.
If you have find out you should use below command to Refresh Sites for the content database. This method synchronizes information between content and config databases.
$db = Get-SPDatabase | where {$_.Name -eq “DatabaseName”}
$db.RefreshSitesInConfigurationDatabase()
If this also does not work you can use below as well but this needs to be done out of office hours.
Dismount-SPContentDatabase “<ContentdBName>”
Mount-SPContentDatabase “” -DatabaseServer “” -WebApplication http://SiteName
Hopefully this well help someone and I just added one more solution in list of solution available.
In case you need more help on this or other SharePoint issues please contact us via our Contact Us page or via our Facebook page or via Twitter