Search This Blog

Wednesday, February 4, 2015

Error - �The given key was not present in the dictionary."

PowerShell command to delete the query suggestion automatically added by SharePoint(suggestions are automatically built based on what search results are actually clicked on. It takes 6 clicks within a year for SharePoint to add a suggestion)), returns an error

Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication "SharePoint Server Search" -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity "ford"

Remove-SPEnterpriseSearchLanguageResourcePhrase : The given key was not present in the dictionary.
At line:1 char:48 + Remove-SPEnterpriseSearchLanguageResourcePhrase <<<<  -SearchApplication "SharePoint Server Search" -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity ford
    + CategoryInfo          : InvalidData: (Microsoft.Offic...eResourcePhrase:   RemoveSearchLanguageResourcePhrase) [Remove-SPEnterp...eResourcePhrase], KeyNotFoundException
    + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.RemoveSearchLanguageResourcePhrase



I could not find a way to remove a query suggestion added by SharePoint. Maybe it is a bug. But we do have an option to block them. This way we can stop them from appearing on the search box.

To block the query suggestion "ford"

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language en-us -Type QuerySuggestionBlockList -Name �ford�
Start-SPTimerJob -Identity �Prepare query suggestions�


To unblock the Query Suggestions "ford"

Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language en-Us -Type QuerySuggestionBlockList -Identity �ford�
Start-SPTimerJob -Identity �Prepare query suggestions�

To view the list of blocked Query Suggestions

Get-SPEnterpriseSearchLanguageResourcePhrase �SearchApplication "SharePoint Server Search" -Language en-us -Type QuerySuggestionBlockList

WARNING: column "Mapping" does not fit into the display and was removed.

Phrase               Type                                        Culture    Author
------               ----                                             -------       ------

ford                 QuerySuggestionBlockList            en-US      domain\user


No comments:

Post a Comment

Propellerads