Training

Juan Carlos

How To Import Search Query Suggestions using PowerShell!

July 6th, 2014 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, SharePoint, Training | Tags: , ,


Undoubtedly, SharePoint search is one of the most powerful features available in the platform not only for the out of the box features but also for the multiple extensibility points provided. In this post we will see how we can improve the search user experience through search query suggestions imported in SharePoint using the power provided by PowerShell.

  • Before going ahead with all the PowerShell staff, we need to define a file with all the query suggestions we want to add to the SharePoint Search. In my case, I have created a simple text file with all these suggestions. As you can see in the file structure, I’m using the QuerySuggestion term as a header in order to simplify the data processing required to extract each suggestion from the file.

image

  • Once we have ready the query suggestions, we need to define the PowerShell code that will import them in the SharePoint Search. This script, which is ready from download in How to import search query suggestions to the SharePoint Search, uses the cmdlet New-SPEnterpriseSearchLanguageResourcePhrase to add each Query Suggestion in a specific Scope (Search Service Application, Site Collection or Site). Finally, in order to provide the query suggestions to final users it’s required to execute the “Prepare query suggestions” Timer Job.

####################################################

# Script that allows to import query suggestions to the SharePoint Search.
# Required Parameters:
#    ->$sInputfile: Query suggestions file.
#    ->$sLanguage: Language for the Query Suggestions.
####################################################

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

$host.Runspace.ThreadOptions = “ReuseThread”

#Definition of the function that imports new query suggestions to SharePoint
function Import-QuerySuggestions
{
param ($sInpuntFile,$sLanguage)
try
{
Write-Host “Importing Query Suggestions..” -ForegroundColor Green
#Checking if the query suggestions file exists
$bFileExists = (Test-Path $sInputFile -PathType Leaf)
if ($bFileExists) {
“Loading $sInputFile for processing…”
$tblData = Import-CSV $sInputFile
} else {
Write-Host “File $sInputFile not found. Stopping the Import Process!” -foregroundcolor Red
exit
}

$ssaSearchApp = Get-SPEnterpriseSearchServiceApplication -Identity “Search Service App”
$spSearchOwner = Get-SPEnterpriseSearchOwner -Level SSA

#Processing the file data
foreach ($row in $tblData){
$sQuerySuggestion=$row.QuerySuggestion.ToString()
Write-Host “Adding $sQuerySuggestion as a Query Suggestion”
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication  $ssaSearchApp -Language $sLanguage -Type QuerySuggestionAlwaysSuggest -Name $sQuerySuggestion -Owner $spSearchOwner
}

#Starting the Timer Job that makes available new query suggestions
$qsTimerJob = Get-SPTimerJob -type “Microsoft.Office.Server.Search.Administration.PrepareQuerySuggestionsJobDefinition”
Write-Host “Starting ” $qsTimerJob.Name ” Timber Job” -ForegroundColor Green
$qsTimerJob.RunNow()
Write-Host “Query Suggestions successfully imported!!” -ForegroundColor Green

}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}

Start-SPAssignment –Global
#Archivo con los Usuarios
$ScriptDir = Split-Path -parent $MyInvocation.MyCommand.Path
$sInputFile=$ScriptDir+ “\QuerySuggestions_Madrid.txt”
$sLanguage=”ES-es”
Import-QuerySuggestions -sInpuntFile $sInputFile -sLanguage $sLanguage
Stop-SPAssignment –Global

Remove-PSSnapin Microsoft.SharePoint.PowerShell

image

  • Of course, you can verify that all the query suggestions has been imported using again the magic and power of Windows PowerShell. In this case, I have prepared a small script that you can get again in the TechNet Script Gallery (How to get all query suggestions defined in a SharePoint Farm!. As you can see in the script, you only need to properly call the Get-SPEnterpriseSearchQueryCantidates in order to get all query suggestions available in the SharePoint farm.

###################################################

# Script that allows to get all the query suggestions already defined in a SharePoint farm.
####################################################

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

$host.Runspace.ThreadOptions = “ReuseThread”

#Definition of the function that gets current query suggestions in the SharePoint farm
function Get-QuerySuggestions
{
try
{
Write-Host “Getting all the query suggestions…” -ForegroundColor Green
$ssaSearchApp = Get-SPEnterpriseSearchServiceApplication -Identity “Search Service App”
$spSearchOwner = Get-SPEnterpriseSearchOwner -Level SSA
Get-SPEnterpriseSearchQuerySuggestionCandidates -SearchApplication $ssaSearchApp -Owner $spSearchOwner
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}

Start-SPAssignment –Global
Get-QuerySuggestions
Stop-SPAssignment –Global

Remove-PSSnapin Microsoft.SharePoint.PowerShell

image

  • Finally, just verify your query suggestions are ready to use in a SharePoint Search Center.

image

And that’s all about how to import Search Query Suggestions to SharePoint using PowerShell. Happy CloudSharing!


Juan Carlos

How to determine the size of the SharePoint Content DBs in a SharePoint Farm!

June 20th, 2014 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, SharePoint, Training | Tags: ,


One of the most common administration tasks when managing a SharePoint environment is to have under control the sizes of the SharePoint content databases available in a SharePoint farm. Although there are several possibilities to get this information, I recommend you to use Windows PowerShell so you can take advantage of the features and great capabilities it provides when doing SharePoint administration task. As you will learn in this article, you can easily get the size for your SharePoint Content Databases by means of a PowerShell Script.

Read the rest of this entry »


Daniel Bakshi

Inception: The journey of nested virtualization

March 25th, 2014 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, Training | Tags: , , , , , ,


If you’ve not been living on the moon, you’ve probably heard of the concept of “Nested Virtualization”.
This is a method of running a Virtual Machine inside a Virtual Machine.

Read the rest of this entry »


Juan Carlos

How to create a Web Performance Test for SharePoint 2013 using VS 2013 Update 1 – Part I!

February 3rd, 2014 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, SharePoint, Training | Tags: , , , ,


In this post I will explain how you can do web performance tests in SharePoint 2013. In the same way you can detect/prevent any issue or problem on your SharePoint Solutions doing an exhaustive analysis using tools like MSOCAF (Microsoft SharePoint Online Code Analysis Framework), you can verify performance and stress abilities on your SharePoint applications by creating web performance and load tests. In this first post I will show you how to create a Web Performance Test for SharePoint 2013 using Visual Studio 2013 (VS 2013) Update 1 in a SharePoint 2013 CloudShare environment.

Read the rest of this entry »


Juan Carlos

Analyzing SharePoint Solutions with MOSCAF – Part II

January 16th, 2014 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, SharePoint, Training | Tags: , , , , ,


In this article I will continue talking about how to use the capabilities provided by MSOCAF (Microsoft SharePoint Online Code Analysis Framewor) for auditing a SharePoint environment in terms of .WSP solutions deployed. If you remember, in my last post about MSOCAF we simply reviewed how to install and use the tool in a CloudShare SharePoint development environment. In this blog post I will continue showing you how MSOCAF is a great tool for analyzing SharePoint solutions and detect any problems introduced by them in a SharePoint farm.

Read the rest of this entry »


Daniel Bakshi

Security in the Cloud!

January 9th, 2014 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, Training | Tags: , ,


lock

So, you have decided to Develop/Test or run Demos/Training in the Cloud. That’s Great! That is the right choice. While we are all aware of the benefits of the Cloud. You now have to put your trust and data somewhere else. So it’s important that you feel safe there.

Read the rest of this entry »


Daniel Bakshi

How To: Measure your TCP Session’s Quality!

December 9th, 2013 | Author: | Filed under: CloudShare, Dev / Test, Training | Tags: , , , , ,


In this Post, I will explain why and when you measure your ‘TCP Session Quality (Starting with: What is ‘TCP Quality’ anyway?).
How you can analyse it yourself, and I’ll share with you a recent example where I had to use it myself. For your comfort – I will write it down in 3 phases.

Read the rest of this entry »


Juan Carlos

What’s new in Office Development Tools for Visual Studio 2013 RC – Part II!

October 21st, 2013 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, SharePoint, Training | Tags: , , ,


In this article I will continue talking about the new Cloud Business App project template we have available in Visual Studio 2013 RC (VS 2013 RC). If you remember, in my last post about this project template we simply reviewed how to use it and how to deploy and debug a dummy application without adding any business entity to the App. In this article, we will see how to add business entities to the App without adding any line of code:

Read the rest of this entry »


Ilana Bercovitz

Demystifying the Cloud

April 9th, 2012 | Author: | Filed under: CloudShare, Demos & POCs, Dev / Test, Training | Tags: , , , , , , ,


People have a difficult time grasping the concept of the cloud. As many ways as I’ve tried to explain where I work to friends and family, I am often asked, “Can you please explain what ‘the cloud’ even is?” Read the rest of this entry »


Ilana Bercovitz

iCloudShare: ProPlus on the iPad

March 19th, 2012 | Author: | Filed under: CloudShare, Training | Tags: , , , ,


Whether you’re an Apple fan or not, you have to admit that the new iPad is pretty fantastic. Read the rest of this entry »