Dienstag, 29. November 2011

Session stuff: Unleash the Power of SharePoint Search with Powershell

Here are the scripts from my PowerShell session at Collaboration Day 2011….:

#Unterschiede zwischen Search und FAST cmdlets:
get-help get-FASTSearchMetadataManagedProperty -examples
get-help get-SPEnterpriseSearchMetadataManagedProperty -examples

#Überblick verschaffen mit:
Get-SPSearchService | select *
Get-SPSearchServiceInstance | select *

#Ping the Search / FAST mit (Send a request to the default content distributor): 
Ping-SPEnterpriseSearchContentService -HostName "demo2010a.contoso.com"

#Übersicht über alle Search Applications:
Get-SPEnterpriseSearchServiceApplication

#Properties mappen
Get-FASTSearchMetadataCrawledProperty -filter VorAngelegtVon
Get-FASTSearchMetadataManagedProperty -Name Author
#$vm = Get-FASTSearchMetadataManagedProperty -Name Author
#$vc = Get-FASTSearchMetadataCrawledProperty -filter VorAngelegtVon
#New-FASTSearchMetadataCrawledPropertyMapping -Managedproperty $vm crawledproperty $vc
Get-FASTSearchMetadataCrawledPropertyMapping  -name Author
_________________________________________________

#Calling KeywordQuery class
$searchSite = "http://intranet"
$site = New-Object Microsoft.SharePoint.SPSite $searchSite
$vc = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery $site
$vc.ResultsProvider = [Microsoft.Office.Server.Search.Query.SearchProvider]::FASTSearch
$vc.ResultTypes = [Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults
#In my case I enabled the FQL syntax and set some other parameters:
$vc.EnableFQL = $true # enable FQL
$vc.RowLimit = 2 # sets the limit of results
$vc.StartRow = 0 # 0 is the default
#Next step is the query, in my case a simple query searching for the term “backup”
#Query / Result
$vc.QueryText = "backup"
$results = $vc.Execute()
write-host "Ergebiss:" -F blue
$results
#Print out the results details:
#result details
$resultTable = $results.Item([Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults)
$rows = $resultTable.Table.Rows
#And getting the properties of each result:
#Each result with properties
write-host "Details:" -F blue
$rows
#This is just interesting and nice, especially getting all the property from the
#“HitHighlightedSummary” and the “HitHighlighted” Property fields.
 
#finding out with filetyps that are in the resultset and how they are distributed
$searchSite = "http://intranet"
$site = New-Object Microsoft.SharePoint.SPSite $searchSite
$vc = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery $site
$vc.ResultsProvider = [Microsoft.Office.Server.Search.Query.SearchProvider]::FASTSearch
$vc.ResultTypes = [Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults
$vc.RowLimit = 1000
# Query String: the "%%" means to search everything, the "-aspx -bdc3 –file" filters to near only documents
$vc.QueryText = "%% -aspx -bdc3 -file"
$results = $vc.Execute()
$resultTable = $results.Item([Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults)
$rows = $resultTable.Table.Rows
$rows| Group-Object FileExtension| Sort-Object count -descending |Format-Table -AutoSize -Property Name,count
$rows| Measure-Object Size -Average -Sum -Maximum –Minimum
_______________________________________________

Get-FASTSearchMetadataRankProfile
#Neues Rank Profil anlegen um PDF Dokumente höher zu gewichten:
$rp = Get-FASTSearchMetadataRankProfile -name default
$nrp = New-FASTSearchMetadataRankProfile -name pdf -template $rp
$fileext = Get-FASTSearchMetadataManagedProperty -Name fileextension
$nrp.CreateManagedPropertyBoostComponent($fileext, "pdf,-200000")
$nrp.update()
Remove-FASTSearchMetadataRankProfile -name pdf
_______________________________________________

#FullText Index
Get-FASTSearchMetadataFullTextIndex -Name content
Get-SPEnterpriseSearchQueryScope -SearchApplication "FastQuery"
#New-SPEnterpriseSearchQueryScope ..... -ExtendedSearchFilter "FullTextIndex=<FullTextIndex>".....
any further question etc.... just mail....

Keine Kommentare:

Kommentar veröffentlichen