1

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.

Screenshot

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.