The Issue
In order to enhance performance, we were tasked with determining the number of search queries sent by our Sitecore CD server (live site) to the SOLR server.
The Resolution
Our initial approach was to examine the Search.log files located in the App_Data/logs folder within the Sitecore instance. However, these files also include search queries initiated from the Sitecore CM server. For instance, a content author may search for an item based on its name or ID using the search box in the content editor. Therefore, we needed a method to filter out queries that are only generated from the actual site and not by the Sitecore client.
We devised a solution based on the observation that any query from the live site always involves a search in one of the computed fields. In our case, this computed field is named __rendered_content_t and it typically contains all the content from the text fields on a page.
We developed the following script with a simple idea in mind:
1. Locate all the Search.log files in the App_Data/logs folder.
2. Exclude queries that do not include the computed field.
3. Provide the count of the remaining queries.
$logfiles = Get-ChildItem -Filter '*Search.log.*' -Path 'C:\inetpub\wwwroot\
cm-local.crowe.com
\App_Data\logs'
$count =0
foreach ($file in $logfiles){$count+=((Select-String -InputObject (Get-Content $file.FullName) -Pattern "_rendered_content" -AllMatches).Matches.Count/2)}
$count
I hope it helps you too!!
Comments
Post a Comment