Suggest endpoint in the Search REST service in SharePoint 2013
-
11-01-2021 - |
문제
I was trying to build a search box with suggestions as user typing using this endpoint "/_api/search/suggest" documentation in SharePoint Search REST API overview.
However it doesn't seems work for me, does anyone came across this and know what might went wrong for me? Thanks for help.
해결책
You have to see if you actually have any query suggestions for the term in question. There is a process that creates the query suggestions and stores them in the Search Service Application. You can use PowerShell to find the Suggestions that you have:
$ssa = Get-SPEnterpriseSearchServiceApplication
$owner = Get-SPEnterpriseSearchOwner -Level Ssa
$manager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager –ArgumentList $ssa
$source = $manager.GetSourceByName("Local SharePoint Results", $owner)
Get-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa `
-Owner $owner -Language en-US -Type QuerySuggestionAlwaysSuggest
If you find that you don't have any phrases you can add them manually with:
New-SPEnterpriseSearchLanguageResourcePhrase
Once you know that is all working your REST request should be (for example "SharePoint":
_api/search/suggest?querytext='SharePoint'&fprequerysuggestions=true
제휴하지 않습니다 sharepoint.stackexchange