Problem Description
Popularity Trends Not Working as Expected in SharePoint 2013 On-Premise Environment.
If all the reports are showing data but you are not getting accurate results, the below steps will help you to resolve the issue. And if you're getting 0 results, it's pretty much the same troubleshooting steps.
A few things to check first from below:
- First make sure your SharePoint Farm is up to date. Check Manage Servers in Farm from Central Admin and make sure all the servers say No Action Required. If the SarePoint Server says Upgrade Available please make sure you install the latest CU and run PSConfig Wizard in all the SharePoint Servers.
- Make sure Search Service Application is configured properly in your Central Admin and that it is connected to your problematic web application by checking from the service connections in Central Admin.
- And also make sure your crawl is running successfully
- Because Usage Analytics is part of Search Servcie Application from SharePoint 2013 Onwards, check that the Usage and Health Data service is up and running.
- Make sure proper events are selected (Analytics Usage, Feature Use, and Page Requests) in the Usage and Health data services.
- Check that the Usage Health data service is connected with the web applciation.
- Make sure Microsoft SharePoint Foundation Usage Data Import and Microsoft SharePoint Foundation Usage Data Processing timers jobs are running.
- Check the SharePoint ULS Logs to check proper logs files are being generated.
- Check for the Event Viewer logs as well.
Troubleshooting steps to resolve the issue
After running the first script from below it returns with no results. We found out the Analytic Timer Jobs on both the Publishing and Consuming servers did not exist. And then we used the second, third and fourth scripts to create the Analytics Timer Job manually along with the job definition types, and then we registered the Analytics Timer Job. All these steps are done by running the second, third and fourth scripts.
We also ran couple of other scripts to check the value of Analytics Timer Job and then we cleared Analytics information from Search and Usage and performed the usage import timer job as well. Upon running all those scripts from below give it at least a day to see the results from the reports.
Step 1
Check if the search settings were configured properly on the site and also the search center.
Run the following commands as below:
- $ssa = Get-SPEnterpriseSearchServiceApplication
- $site = Get-SPSite <site url>
- $result = $ssa.GetRollupAnalyticsItemData(1,[System.Guid]::Empty,$site.ID,[System.Guid]::Empty)
- $filterdate = Get-Date "yyyy-mm-dd"
- $result
If the above commands return no results then move on to Step 2.
Step 2
After further troubleshooting, we found out that the Analytic Timer Jobs on both the Publishing and Consuming servers did not exist.
We created them manually using the following PowerShell script,
- $ssa = Get-SPEnterpriseSearchServiceApplication
-
- $assembly = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search")
-
- $bindingflags = [System.Reflection.BindingFlags]::NonPublic, [System.Reflection.BindingFlags]::Static
Step 3
Analytics job definition types,
- $jobtypes = @("Microsoft.Office.Server.Search.Analytics.UsageAnalyticsJobDefinition", "Microsoft.Office.Server.Search.Analytics.AnalyticsJobDefinition")
Step 4
Register analytics timer jobs,
- foreach ($jobtype in $jobtypes)
-
- {
-
- $type = $assembly.GetType($jobtype)
-
- $registerJob = $type.GetMethod("RegisterJob", $bindingflags)
-
- $registerJob.Invoke($type, $ssa)
-
- }
We also ran the following commands as below,
Step 5
Check values,
- $tj= Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.AnalyticsJobDefinition
- $sa = $tj.GetAnalysis("Microsoft.Office.Server.Search.Analytics.SearchAnalyticsJob")
- $sa
Step 6
After this, clear Analytics information for Search and Usage,
- $ua = Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.UsageAnalyticsJobDefinition
- $ua.DisableTimerJobSchedule()
- $ua.StopAnalysis()
- $ua.ClearAnalysis()
- $ua.EnableTimerJobSchedule()
Step 7
Force Usage Analytics to run, it cannot return null,
- $tj = Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.AnalyticsjobDefinition
- $sa = $tj.GetAnalysis([Microsoft.Office.Server.Search.Analytics.SearchAnalyticsJob])
- $sa.StopAnalysis()
- $sa.ClearAnalysis()
- $sa.StartAnalysis()
- $sa.GetAnalysisInfo()
-
- $ua = Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.UsageAnalyticsJobDefinition
- $ua.DisableTimerJobSchedule()
- $ua.StartAnalysis()
- $ua.EnableTimerJobSchedule()
Step 8
Run the usage import timer job as well,
- $tj = Get-SPTimerJob -Identity ("job-usage-log-file-import")
- $tj.RunNow()
Cause
Not exactly sure what caused this issue, I'm guessing patching might be the culprit.
Just FYI - Upon running all those commands from the top make sure you give it 24 hours to display your results and then everything will be working as expected. :)