any examples of spell suggestions?
Does anyone know where I can find an example of how to use the spelling suggestions feature with the search service sdk? I would like to create a simple page with a textbox and submit button. When the user clicks the button, I want the service to return applicable spelling suggestions for the word(s) that were typed in the text box.
Any ideas?
The definitive source for sample code is the Sample Application hosted here:
But I've pasted a little sample code below which I think might help you get started. Don't forget to replace XXXXXXXXXXX with your own app id.
private SearchResponse GetReferringSite()
{
String myQuery = "Spellign";
MSNSearchService msnSearch = new MSNSearchService();
SearchRequest request = new SearchRequest();
SearchResponse response = null; SourceRequest[] sr = new SourceRequest[1];
sr[0] = new SourceRequest();
sr[0].Source = SourceType.Spelling;
sr[0].ResultFields = ResultFieldMask.All;
sr[0].Count = 50;
sr[0].Offset = 0;
_buildQuery();
request.AppID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
request.Query = myQuery;
request.Requests = sr;
request.CultureInfo = "en-US";
try
{
response = msnSearch.Search(request);
}
catch (Exception e)
{
// This isn't really handling the exception I know
Response.Redirect(Request.RawUrl + "&e=true");
}
return response;
}